Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vincent-thomas/clier
A command line parser and framework for rust
https://github.com/vincent-thomas/clier
cli framework library parser rust
Last synced: about 1 month ago
JSON representation
A command line parser and framework for rust
- Host: GitHub
- URL: https://github.com/vincent-thomas/clier
- Owner: vincent-thomas
- License: mit
- Created: 2023-08-23T15:57:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T20:30:26.000Z (7 months ago)
- Last Synced: 2024-05-22T20:32:59.747Z (7 months ago)
- Topics: cli, framework, library, parser, rust
- Language: Rust
- Homepage: https://docs.rs/clier
- Size: 273 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Clier
## Command Line Argument Parser for Rust
`Clier` is a command line argument parser and command framework for rust.
### Parser
To start a new cli projects run:
```console
$ cargo new demo
$ cargo add clier
```Then define your CLI in `main.rs`:
```rust
use clier_parser::Argv;let args: Argv = Argv::parse();
println!("{:#?}", args);```
And try it out:
```md
$ cargo run -- command subcommand --test=value --no-production --help --try-me=false
Argv {
commands: [
"command",
"subcommand",
],
flags: {
"test": "value",
"production": "false",
"help": "true",
"try-me": "false",
},
}
```### Framework
```rust
use clier::run::ExitCode;
use clier::{CliMeta, Clier, CmdCollection, CmdMeta, Commands};
fn main() {
let clier_builder = Clier::parse().meta(CliMeta {
name: "example-clier".into(),
usage: Some("[command]".into()),
description: "testing".into(),
version: Some((0, 0, 0))
});let app = clier_builder.runnable(vec![Commands::Collection(CmdCollection {
meta: CmdMeta::new("testing", "testing"),
children: Box::from([Commands::Command {
meta: CmdMeta::new("testchild", "testing"),
handler: |_| {
println!("hello");
ExitCode(0)
}
}])
})]);app.run();
}```