[BTNET-5046] Add --silent flag to suppress stdout on success#73
Open
Synesso wants to merge 1 commit intoblock:mainfrom
Open
[BTNET-5046] Add --silent flag to suppress stdout on success#73Synesso wants to merge 1 commit intoblock:mainfrom
Synesso wants to merge 1 commit intoblock:mainfrom
Conversation
Add a --silent CLI flag that redirects stdout to /dev/null at the file descriptor level, suppressing all println!/print_success/print_info output on success. Stderr errors and non-zero exit codes (status command) remain unaffected. Uses libc::dup2 to redirect fd 1 early in run_cli(), avoiding the need to thread a silent parameter through every command function. Amp-Thread-ID: https://ampcode.com/threads/T-019c55a3-ef4f-7638-906d-8193f9ed0830 Co-authored-by: Amp <amp@ampcode.com>
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
Add a
--silentCLI flag that suppresses all stdout output on success, while preserving stderr error output and non-zero exit codes.Implementation
Uses
libc::dup2to redirect stdout (fd 1) to/dev/nullearly inrun_cli(), before any command executes. This avoids threading asilent: boolparameter through every command function.Changes
Cargo.toml: Addedlibcdependencysrc/main.rs: Addedsuppress_stdout()functionsrc/cli/mod.rs: Callsuppress_stdout()when--silentis setsrc/cli/args.rs: Added--silentflag toClistructsrc/commands/status.rs: Minor test cleanupWhat's suppressed
println!calls in command functionsprint_success/print_infohelpersGenerationResult::display()What's NOT suppressed
Testing
All 333 existing tests pass.
Linear: https://linear.app/squareup/issue/BTNET-5046