feat: add --exit-status / -e flag (exit code 1 for false/null/empty output)#1823
Open
sridhar-3009 wants to merge 1 commit into
Open
feat: add --exit-status / -e flag (exit code 1 for false/null/empty output)#1823sridhar-3009 wants to merge 1 commit into
sridhar-3009 wants to merge 1 commit into
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 harehare#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! |
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