Skip to main content

unknown_subcommands

Function unknown_subcommands 

Source
pub fn unknown_subcommands(
    invocations: &[Invocation],
    root: &Command,
) -> Vec<Violation>
Expand description

Of invocations, the ones whose subcommand chain names a subcommand the binary — described by root, its clap command tree — no longer exposes.

Each invocation’s leading tokens are walked against the tree: a token in a subcommand position (the current command takes subcommands) must name one of them, else it is flagged. A global flag (-…) before the subcommand is skipped — together with its value when the command declares the option as value-taking — so a subcommand after a leading flag is still validated. The walk stops at the first command that takes positionals rather than subcommands, so a path argument is never mistaken for a subcommand.