#key-value #struct #override #namespaces #structured-error

clikeys

Namespace-aware KEY=VALUE overrides for nested configuration structs

4 releases

Uses new Rust 2024

0.3.3 Mar 5, 2026
0.3.2 Feb 26, 2026
0.3.1 Feb 8, 2026
0.3.0 Feb 8, 2026

#548 in Configuration

AGPL-3.0-only

16KB
104 lines

clikeys

Namespace-aware KEY=VALUE overrides for nested configuration structs. Pairs well with clap via a repeatable -o/--option KEY=VALUE flag.

Features

  • Nested namespaces: backend.d_model=256 delegates into child structs.
  • Typed parsing: Common scalars (usize, bool, f64, String, ...) with structured errors.
  • Help table: Render grouped option help with defaults via CliKeys::options_help().

Example

use clikeys_derive::CliKeys;

#[derive(Debug, Default, CliKeys)]
pub struct BackendConfig {
    #[clikey(help = "model width")]
    pub d_model: usize,
}

#[derive(Debug, Default, CliKeys)]
pub struct AppConfig {
    pub backend: BackendConfig,
}

let cfg = AppConfig::new_with_options(["backend.d_model=512"])?;
assert_eq!(cfg.backend.d_model, 512);

println!("{}", <AppConfig as clikeys::CliKeys>::options_help());

License

AGPL-3.0-only. See LICENSE for details.

Dependencies

~0.5–1MB
~20K SLoC