Skip to main content

route_to

Function route_to 

Source
pub fn route_to<'t>(
    root: &'t Command<'t>,
    argv: &[&OsStr],
    cmd: &Command<'_>,
) -> Option<Vec<&'t Command<'t>>>
Expand description

The route the words took to a command, for rendering its page unambiguously.

Rebuilt by re-parsing, because Error::Help carries the command and not the way there — putting a route in it would put an allocation in every parser error. The parse is deterministic, so walking the same argv reaches the same place.

ex help config set asks about a command deeper than the parse reached, so the route is extended over Parser::help_span — the words the parser itself resolved as a command path, which is the only reading that cannot mistake a flag’s value for a command name.

None where the command is not below this spec at all, which a caller should treat as a reason to fall back rather than a failure.