cli-settings-derive

Crates.iocli-settings-derive
lib.rscli-settings-derive
version0.3.2
sourcesrc
created_at2023-09-18 19:51:23.93939
updated_at2024-10-05 20:16:59.553943
descriptionManage CLI settings with configuration file(s) and command line parsing, using serde and clap
homepage
repositoryhttps://github.com/mic006/cli-settings-derive
max_upload_size
id976200
size77,441
PALLEAU Michel (mic006)

documentation

https://docs.rs/cli-settings-derive

README

cli-settings-derive

Crates.io docs.rs CI Crates.io

Use a derive macro with annotations on your Command Line Interface settings struct to manage the settings of your application:

  • create an instance with default values (provided by annotations)
  • read each possible configuration file, if it exists:
    • update the fields that are defined in the configuration file
  • parse the command line arguments, and update the relevant fields with the provided argument

By using annotations, each field can be configurable via the configuration file(s) and/or the command line.

cli-settings-derive can be seen as a top layer above

  • serde for the file configuration parsing
  • clap for the command line parsing

See doc.rs documentation for detailed documentation and an example.

See the crate repository for a complete working example, with:

  • clap settings to tune the generated help message (-h)
  • field with custom type and user provided function to parse the value from string
Commit count: 15

cargo fmt