Skip to main content

Module parser

Module parser 

Source
Expand description

Argv tokenizer + resolver.

This is the runtime side of #[derive(FdlArgs)]. The derive macro builds an ArgsSpec from the struct’s fields + attributes, calls parse on std::env::args(), then destructures the resulting ParsedArgs into concrete field values.

The parser is opinionated: it does NOT implement every historical convention. What it supports is documented in the test block below, and that set is the contract.

Structs§

ArgsSpec
Declarative spec of what flags and positionals a CLI accepts. Built by the #[derive(FdlArgs)] output at runtime, consumed by parse.
OptionDecl
Declaration of a single option (long flag, optionally with short alias).
ParsedArgs
Intermediate parsed result, shaped for the derive macro’s field extraction. Absence is encoded by a missing map entry.
PositionalDecl
Declaration of a single positional argument.

Enums§

OptionState
What happened to a single option on the command line.

Functions§

parse
Parse argv against a spec. args[0] is the program name and is ignored.
suggest
“Did you mean” suggestion over a fixed candidate list: returns the first candidate within edit distance 2 of input, if any. The flag-level equivalent is folded into unknown_long_error; this public entry is for the enum-dispatch codegen, which suggests a subcommand name when the user mistypes one (bin triantrain).