Expand description
Dynamic help generation for CLI applications
This module provides the HelpFormatter trait and its default
implementation DefaultHelpFormatter, which generate help text
from a CommandsConfig at runtime.
§Design
- The trait is public and
dyn-compatible so users can supply custom implementations. - The default implementation outputs English-only text; custom implementations choose their own language.
- The formatter is instantiated lazily — only when
--helpis detected — and outputs to the terminal only.
§Extension point
Users of the framework can supply their own formatter via
CliBuilder::help_formatter():
use dynamic_cli::help::HelpFormatter;
use dynamic_cli::config::schema::CommandsConfig;
struct MyFormatter;
impl HelpFormatter for MyFormatter {
fn format_app(&self, config: &CommandsConfig) -> String {
format!("Custom help for {}", config.metadata.prompt)
}
fn format_command(&self, config: &CommandsConfig, command: &str) -> String {
format!("Custom help for command '{command}' in {}", config.metadata.prompt)
}
}Structs§
- Default
Help Formatter - Default help formatter — colored, aligned, English-only output.
Traits§
- Help
Formatter - Generates help text from a runtime configuration.