A minimal CLI framework written in Rust
To use seahorse, add this to your Cargo.toml:
toml
[dependencies]
seahorse = "0.6.1"
bash
$ git clone https://github.com/ksk001100/seahorse
$ cd seahorse
$ cargo run --example single_app
$ cargo run --example multiple_app
```rust use seahorse::{color, App, Command, Context, Flag, FlagType}; use std::env;
fn main() {
let args: Vec
app.run(args);
}
fn helloaction(c: &Context) { let name = &c.args[0]; if c.boolflag("bye") { println!("Bye, {}", name); } else { println!("Hello, {}", name); }
match c.int_flag("age") {
Some(age) => println!("{} is {} years old", name, age),
None => println!("I don't know {}'s age", name),
}
}
fn hellocommand() -> Command { Command::new() .name("hello") .usage("multipleapp hello [name]") .action(helloaction) .flag(Flag::new("bye", "multipleapp hello [name] --bye", FlagType::Bool).alias("b")) .flag( Flag::new( "age", "multiple_app hello [name] --age [age]", FlagType::Int, ) .alias("a"), ) } ```
bash
$ cargo run
$ cargo run John --bye
$ cargo run John --age 30
$ cargo run John -b -a 30
$ cargo run John --age=30
```rust use seahorse::{color, App, Context, Flag, FlagType}; use std::env;
fn main() {
let args: Vec
app.run(args);
}
fn action(c: &Context) { let name = &c.args[0]; if c.bool_flag("bye") { println!("Bye, {:?}", name); } else { println!("Hello, {:?}", name); } }
```
bash
$ cargo run
$ cargo run Bob
$ cargo run Bob --bye
$ cargo run Bob -b
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under MIT license
Contribution to the seahorse crate is organized under the terms of the Contributor Covenant, the maintainer of seahorse, @ksk001100, promises to intervene to uphold that code of conduct.