pub fn builder<T>() -> Result<ConfigBuilder<T>, BuilderError>where
T: Facet<'static>,Expand description
Start configuring an args/config parser for a given type.
This is the main entry point for building layered configuration. The type T
must implement Facet and be properly annotated with figue attributes.
§Example
use facet::Facet;
use figue::{self as args, builder, Driver};
#[derive(Facet)]
struct Args {
#[facet(args::named, default)]
verbose: bool,
#[facet(args::positional)]
file: String,
}
let config = builder::<Args>()
.expect("schema should be valid")
.cli(|cli| cli.args(["--verbose", "input.txt"]))
.build();
let args: Args = Driver::new(config).run().unwrap();
assert!(args.verbose);§Errors
§Errors
Returns an error if:
- The type is not a struct (enums cannot be root types)
- Fields are missing required annotations (
args::positional,args::named, etc.) - Schema validation fails