') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Feat: Add empty json output mode by tdadadavid · Pull Request #844 · It4innovations/hyperqueue · GitHub
Skip to content

Feat: Add empty json output mode - #844

Merged
Kobzol merged 1 commit into
It4innovations:mainfrom
tdadadavid:feat/empty-json-output-mode
Aug 28, 2025
Merged

Feat: Add empty json output mode#844
Kobzol merged 1 commit into
It4innovations:mainfrom
tdadadavid:feat/empty-json-output-mode

Conversation

@tdadadavid

@tdadadavidtdadadavid commented Mar 8, 2025

Copy link
Copy Markdown
Contributor

[✅] Add print_empty to the Outputtrait
[✅] Implemented print_empty for JSON, Cli and Quiet

Fixes: #830

@KobzolKobzol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR! The {} should be only printed for the JSON printer, for the normal printer there's no point in printing an additional empty line.

Actually, it should be easy to solve this fully generally for all commands with this approach:

  • Remember in the JSON printer if anything was printed.
  • Add a finalize_output function to the printer, which will be called just before HQ exits (even if an error has occurred).
  • Implement finalize_output for the JSON printer in a way where it will output {} if nothing was previously printed.

@tdadadavid

Copy link
Copy Markdown
ContributorAuthor

my apologies for the late reply, I am currently writing exams, I will be done next week and pick this up. Thanks!

@tdadadavid
tdadadavid requested a review from KobzolApril 19, 2025 14:26
Comment threadcrates/hyperqueue/src/client/output/json.rs Outdated
Comment threadcrates/hyperqueue/src/client/output/cli.rs Outdated
@Kobzol

Kobzol commented Aug 7, 2025

Copy link
Copy Markdown
Member

Hi, are you still interested in working on this issue? If not, I would finish it.

@tdadadavid

Copy link
Copy Markdown
ContributorAuthor

Good day @Kobzol, I am not available to work on this. Apologies for not stating that earlier.

@Kobzol
Kobzolforce-pushed the feat/empty-json-output-mode branch from 8b40684 to 447cdc5CompareAugust 28, 2025 07:19
@Kobzol

Copy link
Copy Markdown
Member

I finished the PR. Thank you for your contribution!

@Kobzol
Kobzol enabled auto-merge (rebase) August 28, 2025 07:19
@Kobzol
Kobzolforce-pushed the feat/empty-json-output-mode branch from 447cdc5 to bf9edf3CompareAugust 28, 2025 07:28
@Kobzol
Kobzolforce-pushed the feat/empty-json-output-mode branch from bf9edf3 to 7fea69cCompareAugust 28, 2025 07:34
@Kobzol
Kobzol merged commit 97a7b9f into It4innovations:mainAug 28, 2025
9 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hq alloc add does not respect --output-mode json

2 participants

@tdadadavid@Kobzol