Repository navigation
feat: add --exit-status / -e flag (exit code 1 for false/null/empty output) - #1823
Merged
Merged
Conversation
…ty output
Mirrors jq's --exit-status behaviour:
- exit 1 if the output contains only false/null values
- exit 1 if no output was produced
- exit 0 for any other output (including empty string, 0, [], {})
Implementation:
- Add OutputArgs.exit_status: bool (-e / --exit-status)
- Add is_falsy() helper (matches RuntimeValue::None | Boolean(false))
- Use thread_local! HAD_TRUTHY_OUTPUT to track across print() calls
without requiring a large refactor of the streaming output architecture
- After process_batch/streaming, call std::process::exit(1) if
exit_status is set and no truthy value was seen
Closes #1799
Owner
|
@sridhar-3009 It looks like some tests are failing in CI. Could you take a look when you get a chance? Let me know if you need any help! |
print() was reassigning runtime_values to the original RuntimeValues type instead of the .values() slice, breaking the build. The truthy flag also used a thread_local, which never propagates from rayon worker threads back to the main thread once batch processing goes parallel (>10 files). And is_falsy() only checked None/Boolean(false), missing the most common case: select() with no match, which replaces non-matching nodes with an empty value instead of dropping them. Switch HAD_TRUTHY_OUTPUT to an AtomicBool, fix the type mismatch in print(), and treat empty values as falsy. Add tests covering all three.
Merging main into this branch silently dropped the trailing Ok(()) in test_exit_status_parallel_batch and the #[rstest] attribute above test_completion's cases, breaking the build (E0308 / E0433 / "cannot find attribute case"). Restore both.
Owner
|
I took a look and ironed out a few issues. Merging this in now, really appreciate the contribution! |
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
mq 0.6.2 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed ### ✨ New Features - Allow pipeline expressions as function arguments by @VrtxOmega in harehare/mq#1865 - ✨ feat(playground): add drag-and-drop file import to editors by @harehare in harehare/mq#1885 - ✨ feat(mq-web): expose clearHttpCache and clearAllHttpCache APIs by @harehare in harehare/mq#1890 - ✨ feat(mq-ffi): expose engine module/config APIs and mq_version by @harehare in harehare/mq#1893 - ✨ feat(mq-repl): add /save command test and fix missing match arm by @harehare in harehare/mq#1896 - ✨ feat(mq-lsp): add code actions and rename support by @harehare in harehare/mq#1900 - ✨ feat(mq-run): add shell completion subcommand by @harehare in harehare/mq#1902 - ✨ feat(mq-lang): add set_children builtin function by @harehare in harehare/mq#1907 - ✨ feat(mq-lang): add md module for building markdown from scratch by @harehare in harehare/mq#1906 - ✨ feat(mq-lang): make md::doc accept variadic arguments by @harehare in harehare/mq#1909 - feat: add --exit-status / -e flag (exit code 1 for false/null/empty output) by @sridhar-3009 in harehare/mq#1823 - ✨ feat(mq-nodejs): add hover and HTTP cache control APIs by @harehare in harehare/mq#1910 ### 🐛 Bug Fixes - 🐛 fix(cst): support pipeline expressions as function arguments by @harehare in harehare/mq#1866 - 💄 fix(playground): replace alert() with showToast() for error messages by @harehare in harehare/mq#1877 - fix(mq-lang): handle "v"/"V" prefix in semver_parse by @aodihis in harehare/mq#1887 - 🐛 fix(mq-lang): escape embedded double-quotes in csv_stringify by @harehare in harehare/mq#1892 - 🐛 fix(mq-lang): block SSRF/DNS-rebinding in http-import resolver by @harehare in harehare/mq#1901 - 🐛 fix(mq-check): preserve generic arm type when union with concrete None arm by @harehare in harehare/mq#1904 - 🐛 fix(mq-formatter): fix indentation of wrapped def/fn params when inline by @harehare in harehare/mq#1908 - 🐛 fix(mq-wasm): gate OPFS-only helpers behind opfs feature by @harehare in harehare/mq#1911 ### ♻ Refactor - ♻ refactor(http-import): make HTTP fetcher pluggable via HttpFetcher trait by @harehare in harehare/mq#1886 ### 📦 Build / Dependencies - build(deps): bump the dependencies group with 2 updates by @dependabot[bot] in harehare/mq#1882 - build(deps): bump which from 8.0.2 to 8.0.3 in the dependencies group by @dependabot[bot] in harehare/mq#1881 - build(deps-dev): bump the dependencies group in /editors/vscode with 4 updates by @dependabot[bot] in harehare/mq#1878 - build(deps-dev): bump oxlint from 1.68.0 to 1.69.0 in /packages/mq-web in the dependencies group by @dependabot[bot] in harehare/mq#1879 - build(deps-dev): bump the dependencies group in /packages/mq-playground with 2 updates by @dependabot[bot] in harehare/mq#1880 - build(deps-dev): bump js-yaml from 4.1.1 to 4.2.0 in /editors/vscode by @dependabot[bot] in harehare/mq#1883 - build(deps): bump cbindgen from 0.29.3 to 0.29.4 in the dependencies group by @dependabot[bot] in harehare/mq#1888 - 📦 build(nix): update flake.lock to latest nixpkgs and rust-overlay by @harehare in harehare/mq#1889 - build(deps): bump taiki-e/install-action from 2.81.8 to 2.81.9 in the dependencies group by @dependabot[bot] in harehare/mq#1894 - build(deps-dev): bump @types/node from 25.9.2 to 25.9.3 in /editors/vscode in the dependencies group by @dependabot[bot] in harehare/mq#1898 - build(deps): bump the dependencies group with 2 updates by @dependabot[bot] in harehare/mq#1899 - build(deps): bump smallvec from 1.15.1 to 1.15.2 in the dependencies group by @dependabot[bot] in harehare/mq#1903 ## New Contributors * @VrtxOmega made their first contribution in harehare/mq#1865 * @aodihis made their first contribution in harehare/mq#1887 * @sridhar-3009 made their first contribution in harehare/mq#1823 **Full Changelog**: harehare/mq@v0.6.1...v0.6.2 </pre> <p>View the full release notes at <a href="https://github.com/harehare/mq/releases/tag/v0.6.2">https://github.com/harehare/mq/releases/tag/v0.6.2</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!12066
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1799.
Adds
-e/--exit-statustomq, mirroring jq's--exit-statusbehaviour:0falseornullvalues11Everything else — empty string
"",0,[],{}— is truthy and exits0.Usage
Implementation
OutputArgs.exit_status: bool— new clap flag (-e/--exit-status)is_falsy()helper — matchesRuntimeValue::None | Boolean(false)thread_local! { HAD_TRUTHY_OUTPUT }— tracks acrossprint()calls without refactoring the streaming output architectureprocess_batch/process_streaming, callsstd::process::exit(1)when the flag is set and no truthy value was seen