Expand description
§Argser
A library to handle configuration for Programs
§Examples
§Simple Use-Case
name
: The Name
§Code
use argser::argser;
#[argser]
struct Options {
name: String,
}
fn main() {
let opts: Options = argser::parse_cli().unwrap();
println!("Hello {}", opts.name);
}
§Using Subcategories
name
: The Namecon.domain
: The Domaincon.port
: The Port
§Code
use argser::argser;
#[argser]
struct Options {
name: String,
#[argser(subcategory)]
con: Connection,
}
#[argser]
struct Connection {
domain: String,
port: u16,
}
fn main() {
let opts: Options = argser::parse_cli().unwrap();
println!("Hello {}", opts.name);
println!("Connecting to {}:{}", opts.con.domain, opts.con.port);
}
Modules§
- provider
- This represents the Collection of Providers that collect Arguments from various sources.
Structs§
- Argument
Detail - Information regarding a single Argument
Enums§
- Parse
Error - The Error returned when attempting to Parse the Arguments
Traits§
- ArgProvider
- Defines the interface that needs to be implemented by Argument-Providers, this enables users to source the arguments that should be used from different Parts, like CLI-Args, Environment-Variables, etc.
- From
Args - Defines the Interface to parse a Collection of provided Arguments into a single concrete Struct.
- Parse
From Args - Defines the interface to parse a List-Argument Values into single Conecrete Value for a Field in a CLI-Struct
Functions§
- parse_
args_ from_ providers - This will load all the Arguments from the given Providers and then attempt
to parse an instance of
T
from that Collection of Arguments - parse_
cli - This is a simple Wrapper for
parse_args_from_providers
that automatically uses theCli
ArgProvider to collect Arguments and then Parse them
Attribute Macros§
- argser
- This will automatically implement the
argser::FromArgs
trait for the Struct it is applied on, while considering all the Configuration on the Struct and all its parts when generating the implemenatation.