Clap integration for provcfg.
Derive [ClapArgs] alongside provcfg::Configurable to generate a
<Name>Args struct (a clap::Args) plus a From<&<Name>Args> for <Name>Partial impl. A clap-parsed command line then flows into a provcfg
CLI source without a hand-written per-field conversion.
use Parser;
use ;
use ClapArgs;
let cli = parse_from;
// The generated `From<&RegistryArgs>` builds the provcfg partial for us.
let partial: RegistryPartial = .into;
let registry = new.add_cli..unwrap;
assert_eq!;
assert_eq!;
// `--registry-port` was not passed, so `port` keeps its compiled-in default.
assert_eq!;
The ClapArgs derive:
- generates
<Name>Argswith each leaf wrapped inOption<T>and an#[arg(long = "<prefix>-<field>")]auto-derived from the field name; - forwards any user-written
#[arg(...)]attributes; a user-suppliedlong = "..."overrides the auto-derived one; - for
#[configurable(nested)]fields emits#[command(flatten)]into the nested type's ownArgsstruct (which must also deriveClapArgs); - omits
#[configurable(skip)]fields from both the Args struct and theFromimpl.