feat: passthrough fallback when Clap parse fails#200
Open
guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
Open
feat: passthrough fallback when Clap parse fails#200guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
guillaumedeslandes wants to merge 1 commit intortk-ai:masterfrom
Conversation
When RTK cannot parse a command (e.g. `rtk git -C /path status`), instead of exiting with error code 2, it now falls back to running the raw command directly. This keeps developer workflows unbroken. - Replace Cli::parse() with try_parse() + run_fallback() - Add parse_failures SQLite table for failure analytics - Add `rtk gain --failures` / `-F` to view failure log - Fallback preserves stdin/stdout/stderr via Stdio::inherit() - --help and --version still work normally Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
Tested locally — solid approach, needs rebase + 2 fixes before merge. Testing results:
Must fix:
Nice to have (non-blocking):
This will fix #204, #228, #229 and any future unknown-flag issues globally. Great work! |
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
rtk git -C /path status), instead of exiting with Clap error code 2, it now falls back to running the raw command directlyparse_failuresSQLite table to track these events for analyticsrtk gain --failures(-F) to view failure log with recovery rate and top commandsMotivation
Clap calls
std::process::exit(2)beforemain()executes when it can't parse args. This blocks developer workflows for commands RTK doesn't fully model (e.g.git -C, unknown flags). The fallback ensures RTK never breaks a command that would otherwise work.Changes
src/main.rsCli::parse()→try_parse()+run_fallback()withStdio::inherit(), 7 testssrc/tracking.rsparse_failurestable,record_parse_failure(),get_parse_failure_summary(), silent wrapper, 2 testssrc/gain.rs--failures/-Fflag,show_failures()display functionTest plan
cargo fmt --all --checkpassescargo clippy --all-targets— 0 new errorscargo test --all— 387 tests passrtk git -C . status— fallback works, prints[rtk: parse failed, running raw]rtk --help/--version— still work normallyrtk gain --failures— shows failure log after fallback triggers🤖 Generated with Claude Code