Expand description
no_std, zero-allocation, const-generic command-line argument parser.
Everything lives on the stack. No alloc, no Box, no Vec, no String.
Capacity is fixed at compile time through const generics, so the parser
stays within those bounds.
use arf::{Arg, Parser};
let parser = Parser::<4>::new("example", "0.1.0")
.no_auto_help()
.no_auto_version()
.arg(Arg::flag("verbose").short('v').long("verbose"))
.arg(Arg::option("output").short('o').long("output"));
let matches = parser.parse::<4, _>(&["example", "-v", "-o", "out.txt"])?;
assert!(matches.is_present("verbose"));
assert_eq!(matches.value_of("output"), Some("out.txt"));See the Parser docs for the const-generic capacity and
SubCommand for subcommand routing.
Modules§
- fmt
- Help formatter outputs help in a predefined pretty format with padding, option names and default values
Structs§
- Arg
- Definition of a single command-line argument.
- Matches
- Result of a successful parse: argument values plus positionals.
- Parse
Error - A parse failure with optional context borrowed from the input.
- Parser
- Command-line argument parser with optional subcommand support.
- SubCommand
- A subcommand definition with its own fixed-size argument array.
- SubResult
- Result of
Parser::parse_sub: global matches plus optional subcommand matches.
Enums§
Traits§
- From
ArgValue - Parses a value out of a raw argument string.
Type Aliases§
- Parse
Result - Alias for
Result<T, ParseError<'a>>