smart-configThis library provides a couple of command-line extensions for the smart-config library:
Add this to your Crate.toml:
[dependencies]
smart-config-commands = "0.4.0-pre.3"
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:
use std::io;
use smart_config::ConfigSchema;
use smart_config_commands::{MarkdownOptions, Printer};
let mut schema = ConfigSchema::default();
// Add configurations to the schema...
Printer::stdout().print_markdown_reference(&schema, &MarkdownOptions::default(), |_| true)?;
io::Result::Ok(())
For a binary exposing configuration utilities, prefer a command name based on the task, for example:
config docs > docs/src/setup/configuration.md
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:
The output will contain deserialization errors for all available params:
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.
Distributed under the terms of either
at your option.