fix(wget): detect -O - in trailing args absorbed by Clap#793
Open
gghez wants to merge 2 commits intortk-ai:developfrom
Open
fix(wget): detect -O - in trailing args absorbed by Clap#793gghez wants to merge 2 commits intortk-ai:developfrom
gghez wants to merge 2 commits intortk-ai:developfrom
Conversation
When flags like --no-check-certificate precede -O -, Clap's trailing_var_arg absorbs all remaining tokens into the args vec, leaving the output field as None. This caused RTK to route through run() instead of run_stdout(), so the bare "-" was passed to wget as a positional URL argument. Scan trailing args for -O - / -O- / --output-document - patterns and strip them before routing to run_stdout(). Fixes rtk-ai#716 Signed-off-by: gghez <gghez@users.noreply.github.com>
Collaborator
📊 Automated PR Analysis
SummaryFixes a bug where Review Checklist
Linked issues: #716 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
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
When flags like
--no-check-certificateprecede-O -, Clap'strailing_var_argabsorbs all remaining tokens into theargsvec, leaving theoutputfield asNone. This caused RTK to route throughrun()instead ofrun_stdout(), so the bare-was passed to wget as a positional URL argument — producing:I added two helper functions in
wget_cmd.rs:has_stdout_output_flag()— scans trailing args for-O -/-O-/--output-document -/--output-document=-strip_output_flag()— removes those tokens so they aren't duplicated whenrun_stdout()adds its own-O -The routing in
main.rsnow checks both the Clap-parsedoutputfield and the trailing args before deciding which path to take.Tested with:
rtk wget https://example.com -O -(already worked)rtk wget https://example.com --no-check-certificate -O -(was broken, now fixed)rtk wget -O - https://example.com(already worked)rtk wget https://example.com(no regression, still downloads to file)14 unit tests added covering all
-Oflag variants and edge cases.Fixes #716