| Crates.io | dynamic-cli |
| lib.rs | dynamic-cli |
| version | 0.1.1 |
| created_at | 2026-01-11 15:42:25.735474+00 |
| updated_at | 2026-01-12 10:40:09.302024+00 |
| description | A framework for building configurable CLI and REPL applications from YAML/JSON configuration files |
| homepage | https://github.com/biface/dcli |
| repository | https://github.com/biface/dcli |
| max_upload_size | |
| id | 2035983 |
| size | 491,231 |
A powerful Rust framework for creating configurable CLI and REPL applications via YAML/JSON files.
Define your command-line interface in a configuration file, not in code. β¨
English | FranΓ§ais
Add to your Cargo.toml:
[dependencies]
dynamic-cli = "0.1.1"
1. Create a configuration file (commands.yaml):
metadata:
version: "1.0.0"
prompt: "myapp"
prompt_suffix: " > "
commands:
- name: greet
aliases: [hello, hi]
description: "Greet someone"
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: "greet_handler"
global_options: []
2. Implement your command handlers:
use dynamic_cli::prelude::*;
use std::collections::HashMap;
// Define your application context
#[derive(Default)]
struct MyContext {
// Your application state
}
impl ExecutionContext for MyContext {
fn as_any(&self) -> &dyn std::any::Any { self }
fn as_any_mut(&mut self) -> &mut dyn std::any::Any { self }
}
// Implement the command handler
struct GreetCommand;
impl CommandHandler for GreetCommand {
fn execute(
&self,
_context: &mut dyn ExecutionContext,
args: &HashMap<String, String>,
) -> dynamic_cli::Result<()> {
let name = args.get("name").unwrap();
let loud = args.get("loud").map(|v| v == "true").unwrap_or(false);
let greeting = format!("Hello, {}!", name);
println!("{}", if loud { greeting.to_uppercase() } else { greeting });
Ok(())
}
}
fn main() -> dynamic_cli::Result<()> {
CliBuilder::new()
.config_file("commands.yaml")
.context(Box::new(MyContext::default()))
.register_handler("greet_handler", Box::new(GreetCommand))
.build()?
.run()
}
3. Run your application:
# CLI mode
$ myapp greet Alice
Hello, Alice!
$ myapp greet Bob --loud
HELLO, BOB!
# REPL mode
$ myapp
myapp > greet Alice
Hello, Alice!
myapp > help
Available commands:
greet [name] - Greet someone
myapp > exit
The examples directory contains complete examples:
Run any example:
cargo run --example simple_calculator
dynamic-cli is organized into focused modules:
# Run all tests
cargo test --all-features
# Run with coverage
cargo tarpaulin --out Html
# Check code quality
cargo clippy --all-features -- -D warnings
Current test statistics:
We welcome contributions from everyone! Here's how you can help:
# Fork and clone
git clone https://github.com/biface/dcli.git
cd dynamic-cli
# Create a branch
git checkout -b feature/my-feature
# Make your changes and test
cargo test --all-features
cargo clippy --all-features
# Commit and push
git commit -am "Add awesome feature"
git push origin feature/my-feature
Before submitting a pull request:
cargo fmt)cargo test --all-features)cargo clippy --all-features -- -D warnings)This project follows a Code of Conduct to ensure a welcoming environment:
Read the complete contributing guide β
Licensed under your choice of:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Need help?
Found a security vulnerability?
Please report it privately to the maintainers.
If you find dynamic-cli useful, please:
Last updated: 2026-01-12