Skip to main content

parse

Function parse 

Source
pub fn parse(
    tool: &Tool,
    args: &[String],
) -> Result<ParsedToolArguments, String>
Expand description

Parses arguments using a validated tool definition’s command-line surface.

args excludes the tool name. Options, subcommands, aliases, positionals, defaults, help, and constraints follow the same rules for native CLI and guest callers.

A command whose only positional surface is a verbatim tail after --, and that has no subcommands, does not need the separator. Its declared options and flags and the generated help are read until the first other token, which starts the tail; an unknown option starts it too. From there every token goes to the tail unchanged. An explicit -- still starts the tail, which is how a token that is also one of the command’s options reaches the tail.

Environment-variable metadata never reads process environment values, and this function gives it no variables: see parse_with_variables.

§Errors

Returns a diagnostic for an invalid command line or a value that fails canonical validation.