Crate badargs

Source
Expand description

§badargs

A fully type-safe argument parser without any proc macros!

Declare your arguments with structs. You probably want to use the macro for that

use badargs::arg;

arg!(Force: "force", 'f' -> bool);
arg!(OutFile: "output", 'o' -> String);

The recommended way to use badargs is by invoking the macro badargs!

use badargs::arg;

arg!(Force: "force", 'f' -> bool);
arg!(OutFile: "output", 'o' -> String);

let args = badargs::badargs!(Force, OutFile);

You can also invoke the badargs() function directly

Getting the values is done using the BadArgs::get function

use badargs::arg;
arg!(Force: "force", 'f' -> bool);
arg!(OutFile: "output", 'o' -> String);

let args = badargs::badargs!(Force, OutFile);

let force: Option<&bool> = args.get::<Force>();
let out_file = args.get::<OutFile>();

Macros§

arg
Declare your arguments using this macro.
badargs
A shorthand for calling the badargs main function

Structs§

BadArgs
The struct containing parsed argument information

Enums§

SchemaError
Invalid schema

Traits§

CliArg
Implemented by a user provided type that contains all info for a single command line argument
CliReturnValue
A type that could be parsed from command line arguments

Functions§

badargs
Parses the command line arguments based on the provided schema S

Type Aliases§

Result