Repository navigation
Conversation
📊 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. |
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
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 <[email protected]>
7c457c6 to
7ec2d29
Compare
|
Rebased! Only conflict was in |
…ag-parsing # Conflicts: # CHANGELOG.md # src/cmds/cloud/wget_cmd.rs # src/main.rs
Routing moved from src/main.rs to src/lib.rs on develop; port the -O - detection there.
- Use arg_tokenizer with wget's value-taking flags (from wget --help, GNU Wget 1.25) instead of a string scan, as src/cmds/README.md asks. - Catches clustered short flags after the URL: 'wget URL -qO-' still lost the page; '-qO-' is now stripped to '-q'. - A '-' that is another flag's value (--header -, -U -O-) or follows '--' no longer counts as stdout output. - cargo fmt under style edition 2024; collapsible if fixed.
pszymkowiak
left a comment
There was a problem hiding this comment.
Hi @gghez, sorry this sat for seven months without a review. The bug is still there on develop: rtk wget https://example.com --no-check-certificate -O - prints example.com ok | - | ? instead of the page.
I've pushed two commits to your branch:
- merged develop and moved the check to
src/lib.rs(routing leftmain.rs) has_stdout_output_flag/strip_output_flagnow go througharg_tokenizerwith wget's value-taking flags (fromwget --help), which develop asks for now. That also catcheswget URL -qO-, which your version missed (-qO-becomes-q), and stops treating a-that belongs to another flag (--header -) as stdout.- fmt under the 2024 style edition, one clippy fix, 4 more tests
Checked against real wget on 9 commands: stdout matches plain wget byte for byte in every case (develop loses the page in 5 of them). Full test suite passes.
Approving, thanks for the fix.
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