Expand description
Command-line extensions for smart-config library.
The extensions are as follows:
- Printing help for configuration params with optional filtering.
- Printing a Markdown reference for generated documentation.
- Debugging param values and deserialization errors.
All extensions are encapsulated in Printer.
§Examples
See the crate readme or the examples dir for captured output samples.
§Printing help
use smart_config::ConfigSchema;
use smart_config_commands::Printer;
let mut schema = ConfigSchema::default();
// Add configurations to the schema...
Printer::stderr().print_help(&schema, |_| true)?;§Generating Markdown reference docs
use smart_config::ConfigSchema;
use smart_config_commands::{MarkdownOptions, Printer};
let mut schema = ConfigSchema::default();
// Add configurations to the schema...
Printer::stderr().print_markdown_reference(&schema, &MarkdownOptions::default(), |_| true)?;In binaries, prefer a task-oriented command name such as config docs; the API name is
format-specific because this method emits Markdown.
§Debugging param values
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 repository...
Printer::stderr().print_debug(&repo, |param_ref| {
// Allows filtering output params
param_ref.canonical_path().starts_with("test.")
})?;Structs§
- EnvVar
Options - Options for rendering environment variable names.
- Markdown
Options - Options controlling Markdown reference generation.
- Param
Ref - Reference to a parameter on a configuration.
- Printer
- Wrapper around an I/O writer. Will style the output with ANSI sequences if appropriate.