feat(argv): answer the help subcommand - #872
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR adds parser-owned
Confidence Score: 4/5The PR is not yet safe to merge because the previously reported parser-semantic mismatch remains and produces incompatible outcomes for the same specification and arguments. usage-argv now treats Files Needing Attention: argv/src/lib.rs, lib/src/parse.rs, and the shared conformance corpus Important Files Changed
Reviews (6): Last reviewed commit: "feat(argv): answer the `help` subcommand" | Re-trigger Greptile |
e92d4fe to
d088543
Compare
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes. Shadow comparisonParsing
|
439663f to
8acbf48
Compare
8acbf48 to
439663f
Compare
`ex help config ls` — the third of the three ways a user asks, after `--help` and `-h`, and the one the page has been advertising all along: every page with a Commands section ends it with "help Print this message or the help of the given subcommand(s)", and typing that word did nothing. The page decides where it works: it prints that line where there are subcommands, so that is where the word is answered. To a leaf, `help` is a word like any other, and `mise config set help` still sets the key called help. Asked after the subcommand lookup, so a CLI that declares a `help` of its own keeps it, arguments and all — the same rule the two flags follow. The words after it name a command, resolved without descending into it: they are a question about a command rather than an invocation of it, so nothing binds and a word naming no command stops the walk rather than failing — `deep help config nonsense` answers about `config`, which is the most useful page it can give. Aliases resolve, since the question is about the command and not the spelling. Costs nothing measurable at mise's scale (29,949 instructions for `mise use -g node@20`, against 29,961 before): the guard short-circuits on every command that has no subcommands. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
439663f to
a08f697
Compare
ex help config ls— the command a CLI with subcommands is expected to have, andthe third of the three ways a user asks:
--help,-h, and this.Supplied on the same terms as the two flags: answered by the parser, absent from
the page unless the spec declares it, so a spec stays a description of what its
author wrote rather than of what the parser adds.
Asked after the subcommand lookup, so a CLI that means something else by
helpkeeps its own command and its own arguments, and only where there are
subcommands — to a leaf,
helpis a word like any other, andmise config set helpstill sets the key called help.The words after it name a command, resolved without descending into it: they are
a question about a command rather than an invocation of it, so nothing binds and
a word naming no command stops the walk rather than failing —
deep help config nonsenseanswers aboutconfig, which is the most useful page it can give.Aliases resolve, since the question is about the command and not the spelling.
Costs nothing measurable at mise's scale (29,949 instructions for
mise use -g node@20, against 29,961 before): the guard short-circuits on every command thathas no subcommands.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Stack created with GitHub Stacks CLI • Give Feedback 💬
Note
Low Risk
Localized parser extension mirroring existing help-flag handling, with strong conformance coverage and no changes to auth, persistence, or public API shape beyond new behavior.
Overview
The argv parser now treats
helpas a built-in help request (like--help/-h) wherever a command has subcommands—the same place help text already advertises it.When the current token is
help, the parser walks following argv words as a subcommand path (names and aliases) without descending into those commands, then returnsError::Helpwithlong: truefor the resolved command. Unknown path segments stop the walk and still yield help for the deepest match (e.g.help config nonsense→ config’s page). The check runs after real subcommand matching so a user-declaredhelpsubcommand wins; on leaf commandshelpstays a normal positional value.A small
find_namedhelper resolves subcommands by name or alias for that path walk. Conformance tests cover nested paths, aliases, partial paths, leaves, customhelpcommands, and alignment with rendered help pages.Reviewed by Cursor Bugbot for commit a08f697. Bugbot is set up for automated code reviews on this repo. Configure here.
Tests
conformance/tests/help_request.rsgains five: the page is about the command the words name,including a nested one and an alias; a half-recognised path answers about as far as it got; a
leaf binds
helpas an ordinary word; and a CLI declaring its ownhelpcommand keeps it,arguments and all.
Each guard was mutation-checked — dropping the
subcommands.is_empty()condition, askingbefore the subcommand lookup, answering with the short form, and matching names but not
aliases each fail a test.
The page and the parser now agree
Every page with a Commands section already ended it with
help Print this message or the help of the given subcommand(s)— usage-lib's template writes that line unconditionally, and so does ours. The word simply did nothing. A test asserts the promise and the behavior share one condition: the line appears on a page with subcommands, and that is exactly where the word is answered.AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5; version: unavailable.