Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,10 @@ Groups are the opposite case: `Command::get_groups`, `ArgGroup::get_args` and
carries doc-comment or explicit help, hidden canonical values, hidden `alias`,
visible `visible_alias`, and case-insensitive matching through its static metadata
and lossless KDL emission.
- [x] **`infer_subcommands` / `infer_long_args`** — unambiguous prefixes of
command names, command aliases, long flags, and long aliases are accepted
only when one declaration matches. Both settings are inherited by child
commands and carried through KDL, usage-lib, generated Rust, generated Go,
and Go's runtime spec builder. `#[usage(infer_subcommands, infer_long_args)]`
is the typed spelling. clap exposes setters but no public getters for these
global settings, so `clap_usage` cannot recover them from an existing
`Command`; a migration declares them on the usage type.
- [x] **`infer_subcommands` / `infer_long_args` are intentional non-goals.** Long
flags and subcommands require exact spellings. Diagnostics may suggest what
was probably meant, but accepting a prefix would let a later declaration
change or invalidate an existing invocation.
- [x] **`external_subcommand`** — an unmatched word is forwarded with the rest
of argv. Spec `external_subcommand`, usage-lib, usage-argv, the derive
(`#[usage(external_subcommand)]` on a catch-all `Vec` variant), and the
Expand Down
8 changes: 1 addition & 7 deletions argv/src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,6 @@ pub fn route_to<'t>(
if route.is_empty() {
route.push(root);
}
let mut infer_subcommands = route.iter().any(|cmd| cmd.infer_subcommands);

// Already there for `--help`, whose span is empty. For the `help` word the parse stopped at
// the command that *saw* it, and the words naming the one being asked about are exactly the
Expand All @@ -1270,13 +1269,8 @@ pub fn route_to<'t>(
// that reached here did. Matching on name and alias together instead answered with
// whichever subcommand came first, which for a colliding word is a different command
// than the one the parser selected.
let next = if infer_subcommands {
crate::find_prefixed(here, word)?
} else {
crate::find_named(here, word)?
};
let next = crate::find_named(here, word)?;
route.push(next);
infer_subcommands |= next.infer_subcommands;
}
// Only if the walk actually arrived: a caller should fall back rather than be handed a
// page about some other command.
Expand Down
Loading