| Crates.io | accordion |
| lib.rs | accordion |
| version | 0.1.2 |
| created_at | 2025-04-16 14:57:46.24174+00 |
| updated_at | 2025-05-06 09:02:01.977026+00 |
| description | Simple library for Command Line Interface parsing with no magic behind the scenes |
| homepage | |
| repository | https://github.com/pipangry/accordion |
| max_upload_size | |
| id | 1636555 |
| size | 46,731 |
Creating CommandStream – assembled parser for multiple commands
use accordion::cli::command::{Arg, Command, Value};
use accordion::cli::{CommandStream, DefaultPrettifier};
use accordion::cli::consumer::GenericConsumer;
const CARGO: Command<Vec<Value>> = Command::new_from(
"cargo",
"Example description",
&[
Arg::default("subcommand"),
Arg::flag("version", Some("v"), GenericConsumer(&[]))
],
cargo
);
let command_stream = CommandStream::new(vec![
CARGO
// Add more as needed
]);
// Parsing input from user
match command_stream.parse("cargo -v") {
Ok(_) => {},
// For potential errors we use prettifier
Err(e) => println!("{}", command_stream.prettify(e))
}
fn cargo(_: Vec<Value>) {}
help commanderror[cargo]: 'Missing arguments: ["type", "args"]' – returned by command 'cargo'
--> source: cargo
| cargo ... <type> <args>
| ^^^^^^^^^^^^^
help: Consider adding these arguments.