smart-config-commands

Crates.iosmart-config-commands
lib.rssmart-config-commands
version0.4.0-pre
created_at2025-06-05 12:31:55.153304+00
updated_at2025-09-23 12:30:00.25062+00
descriptionCommand-line extensions for `smart-config` library
homepage
repositoryhttps://github.com/matter-labs/smart-config
max_upload_size
id1701407
size201,337
(CratesMatterLabs)

documentation

README

Command-Line Extensions for smart-config

Build status License: MIT OR Apache-2.0 rust 1.86+ required

Docs: crate docs (main)

This library provides a couple of command-line extensions for the smart-config library:

  • Printing help for configuration params with optional filtering.
  • Debugging param values and deserialization errors.

Usage

Add this to your Crate.toml:

[dependencies]
smart-config-commands = "0.4.0-pre"

Printing help on config params

use std::io;
use smart_config::ConfigSchema;
use smart_config_commands::Printer;

let mut schema = ConfigSchema::default();
// Add configurations to the schema...

Printer::stdout().print_help(&schema, |param_ref| {
    // Allows filtering output params.
    param_ref.param.name.contains("test")
})?;
io::Result::Ok(())

Example output is as follows:

Example output for print_help

Debugging param values

use std::io;
use smart_config::{ConfigSchema, ConfigRepository};
use smart_config_commands::Printer;

let mut schema = ConfigSchema::default();
// Add configurations to the schema...
let mut repo = ConfigRepository::new(&schema);
// Add sources to the repo...

Printer::stdout().print_debug(&repo, |_| true)?;
io::Result::Ok(())

Example output is as follows:

Example output for print_debug

The output will contain deserialization errors for all available params:

Example output for print_debug

Outputting JSON / YAML

The library can fancy-print JSON and YAML. This be used together with smart-config tooling to produce default / example configs, diffs with default param values etc. See the example for a couple of use cases.

Example of fancy-printed YAML

License

Distributed under the terms of either

at your option.

Commit count: 41

cargo fmt