Command-Line Extensions for smart-config
This library provides a couple of command-line extensions for the smart-config library:
- Printing help for configuration params with optional filtering.
- Generating a Markdown reference for configuration params.
- Debugging param values and deserialization errors.
Usage
Add this to your Crate.toml:
[]
= "0.4.0-pre.4"
Printing help on config params
use io;
use ConfigSchema;
use Printer;
let mut schema = default;
// Add configurations to the schema...
stdout.print_help?;
Ok
Example output is as follows:
Generating Markdown reference docs
use io;
use ConfigSchema;
use ;
let mut schema = default;
// Add configurations to the schema...
stdout.print_markdown_reference?;
Ok
For a binary exposing configuration utilities, prefer a command name based on the task, for example:
config docs > docs/src/setup/configuration.md
Debugging param values
use io;
use ;
use Printer;
let mut schema = default;
// Add configurations to the schema...
let mut repo = new;
// Add sources to the repo...
stdout.print_debug?;
Ok
Example output is as follows:
The output will contain deserialization errors for all available params:
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.
License
Distributed under the terms of either
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.