Expand description
Configuration module
This module provides functionality for loading, parsing, and validating YAML/JSON configuration files that define CLI/REPL commands.
§Module Structure
schema: Data structures for configurationloader: Functions to load configuration filesvalidator: Configuration validation logic
§Quick Start
use dynamic_cli::config::{loader::load_config, validator::validate_config};
// Load configuration from file
let config = load_config("commands.yaml")?;
// Validate the configuration
validate_config(&config)?;
println!("Loaded {} commands", config.commands.len());§Configuration File Format
§YAML Example
metadata:
version: "1.0.0"
prompt: "myapp"
prompt_suffix: " > "
commands:
- name: hello
aliases: [hi]
description: "Say hello"
required: false
arguments:
- name: name
arg_type: string
required: true
description: "Name to greet"
validation: []
options:
- name: loud
short: l
long: loud
option_type: bool
required: false
description: "Use uppercase"
choices: []
implementation: "hello_handler"
global_options: []§JSON Example
{
"metadata": {
"version": "1.0.0",
"prompt": "myapp"
},
"commands": [
{
"name": "hello",
"aliases": [],
"description": "Say hello",
"required": false,
"arguments": [],
"options": [],
"implementation": "hello_handler"
}
],
"global_options": []
}Re-exports§
pub use schema::ArgumentDefinition;pub use schema::ArgumentType;pub use schema::CommandDefinition;pub use schema::CommandsConfig;pub use schema::Metadata;pub use schema::OptionDefinition;pub use schema::ValidationRule;pub use loader::load_config;pub use loader::load_json;pub use loader::load_yaml;pub use validator::validate_argument_types;pub use validator::validate_command;pub use validator::validate_config;