fix: route ask/docs/diff options past root-command flag collisions#52
Merged
Merged
Conversation
The root command defines -b/--branch, --model, --format, --full-clone, --keep-temp, etc. Because the root has options + an action alongside subcommands, Commander captures those flags at the root before the subcommand parses them, so several subcommand options were silently ignored: - ask: --branch, --model - docs: --branch - diff: --format, --full-clone, --keep-temp Extract pure, tested getFlagValue/hasFlag helpers in src/utils.ts and read the affected options from raw argv (the approach diff already used for --output). Removed the masking default on diff --format so the fallback can take effect (runPullRequestDiff already defaults to markdown). Tests: getFlagValue/hasFlag unit tests; an in-process cli routing test that mocks the command runners and asserts values reach them; a real-CLI diff e2e asserting --format html and --keep-temp take effect. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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
Fixes a repo-wide CLI correctness bug: several subcommand options were silently ignored because their flag names collide with the root command.
Root cause
The root
bootcampcommand defines-b/--branch,--model,--format,--full-clone,--keep-temp, etc. Because the root has its own options + action alongside subcommands, Commander captures those flags at the root before the subcommand parses them. The affected options:ask:--branch,--modeldocs:--branchdiff:--format,--full-clone,--keep-temp(
bootcamp healthhad the same issue, fixed in #50;diff --outputwas already worked around.)Fix
getFlagValue(args, flags)andhasFlag(args, flags)intosrc/utils.ts.cli.tsreads the colliding options from raw argv via these helpers (the approachdiffalready used for--output).diff --formatso the argv fallback can take effect (runPullRequestDiffalready defaults tomarkdown).Testing
test/utils.test.ts— 9 new unit tests forgetFlagValue/hasFlag(value +=forms, aliases, absence, repeats) — utils.ts now at 100% coveragetest/cli-option-routing.test.ts— in-process test that mocks the command runners, setsprocess.argv, and assertsask/docs/diffreceive the correct valuestest/e2e/diff-command.e2e.test.ts— new real-CLI e2e (offline, fake GitHub API + bare repo) asserting--format htmlproducesDIFF.htmland--keep-tempretains the clonelint✓,typecheck✓,build✓, full unit suite 1062 passing, coverage above thresholds, diff e2e ✓