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. The walk stops at the first flag (-…) — subcommands precede options in clap — and at the first command that takes positionals rather than subcommands, so a path argument is never mistaken for a subcommand.