fix: replace CLI panics with clean errors on bad IP args and closed stdout - #305
Draft
code-inflation wants to merge 2 commits into
Draft
code-inflation wants to merge 2 commits into
code-inflation wants to merge 2 commits into
Conversation
…tdout - Validate --ipv4/--ipv6 values with clap value parsers so invalid addresses produce a usage error with exit code 2 instead of a panic (previously exit 101), and collapse the three duplicate client construction branches in main.rs into one. - Route all stdout writes through new tolerant helpers (src/stdout.rs): a broken pipe (e.g. the consumer of 'cfspeedtest -o json | jq' exiting early) is now tolerated silently instead of panicking with exit 101; unexpected stdout write errors are reported once on stderr. Completion scripts are buffered in memory because clap_complete panics on write errors. - Add regression tests for both behaviors.
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.
Fixes two ways the CLI could crash with exit code 101: invalid
--ipv4/--ipv6values panicked at client construction instead of failing argument validation,
and any write to a closed stdout panicked (e.g.
cfspeedtest -o json | jqwithjqexiting early). Invalid addresses now get a clap usage error and exit 2,rejecting an IPv6 value for
--ipv4and vice versa; broken pipes are toleratedsilently and the run finishes with its normal exit code; unexpected stdout write
errors are reported once on stderr. Completion scripts are buffered in memory
because
clap_completepanics on write errors. No new flags;--ipv4/--ipv6still accept the same values and the library API is unchanged.