Skip to content

Commit

Permalink
Merge pull request #54 from ksk001100/feature/fix-help
Browse files Browse the repository at this point in the history
Help Improvements
  • Loading branch information
ksk001100 authored Oct 31, 2020
2 parents f6f496f 00e6c58 commit 8963ae3
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 99 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
[package]
name = "seahorse"
version = "1.0.0"
version = "1.1.0"
authors = ["ksk001100 <[email protected]>"]
edition = "2018"
keywords = [
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 24,7 @@ To use seahorse, add this to your Cargo.toml:

```toml
[dependencies]
seahorse = "1.0.0"
seahorse = "1.1.0"
```

## Example
Expand Down Expand Up @@ -53,6 53,7 @@ use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let app = App::new(env!("CARGO_PKG_NAME"))
.description(env!("CARGO_PKG_DESCRIPTION"))
.author(env!("CARGO_PKG_AUTHORS"))
.version(env!("CARGO_PKG_VERSION"))
.usage("cli [args]")
Expand All @@ -76,6 77,7 @@ use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let app = App::new(env!("CARGO_PKG_NAME"))
.description(env!("CARGO_PKG_DESCRIPTION"))
.author(env!("CARGO_PKG_AUTHORS"))
.version(env!("CARGO_PKG_VERSION"))
.usage("cli [name]")
Expand All @@ -97,8 99,9 @@ fn add_action(c: &Context) {

fn add_command() -> Command {
Command::new("add")
.description("add command")
.alias("a")
.usage("cli add(a****) [nums...]")
.usage("cli add(a) [nums...]")
.action(add_action)
}

Expand All @@ -109,6 112,7 @@ fn sub_action(c: &Context) {

fn sub_command() -> Command {
Command::new("sub")
.description("sub command")
.alias("s")
.usage("cli sub(s) [nums...]")
.action(sub_action)
Expand All @@ -135,18 139,19 @@ use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let app = App::new(env!("CARGO_PKG_NAME"))
.description(env!("CARGO_PKG_DESCRIPTION"))
.author(env!("CARGO_PKG_AUTHORS"))
.version(env!("CARGO_PKG_VERSION"))
.usage("cli [name]")
.action(default_action)
.flag(
Flag::new("bye", FlagType::Bool)
.usage("cli [name] --bye(-b)")
.description("Bye flag")
.alias("b"),
)
.flag(
Flag::new("age", FlagType::Int)
.usage("cli [name] --age(-a)")
.description("Age flag")
.alias("a"),
)
.command(calc_command());
Expand Down Expand Up @@ -189,12 194,13 @@ fn calc_action(c: &Context) {

fn calc_command() -> Command {
Command::new("calc")
.description("calc command")
.alias("cl, c")
.usage("cli calc(cl, c) [nums...]")
.action(calc_action)
.flag(
Flag::new("operator", FlagType::String)
.usage("cli calc [nums...] --operator(-op) [add | sub]")
.description("Operator flag(ex. cli calc --operator add 1 2 3)")
.alias("op"),
)
}
Expand Down
8 changes: 5 additions & 3 deletions examples/multiple_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 11,7 @@ fn main() {
.action(|c: &Context| println!("{:?} : {}", c.args, c.bool_flag("bool")))
.flag(
Flag::new("bool", FlagType::Bool)
.usage("multiple_app [args] --bool(-b)")
.description("bool flag")
.alias("b"),
)
.command(add_command())
Expand Down Expand Up @@ -52,18 52,19 @@ fn hello_action(c: &Context) {

fn hello_command() -> Command {
Command::new("hello")
.description("hello command")
.usage("multiple_app hello(he, h) [name]")
.alias("he")
.alias("h")
.action(hello_action)
.flag(
Flag::new("bye", FlagType::Bool)
.usage("multiple_app hello [name] --bye(-b)")
.description("bye flag")
.alias("b"),
)
.flag(
Flag::new("age", FlagType::Int)
.usage("multiple_app hello [name] --age(-a, -ag) [age]")
.description("age flag")
.alias("a")
.alias("ag"),
)
Expand All @@ -76,6 77,7 @@ fn add_action(c: &Context) {

fn add_command() -> Command {
Command::new("add")
.description("add command")
.usage("multiple_app add [num...]")
.action(add_action)
}
2 changes: 1 addition & 1 deletion examples/single_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 13,7 @@ fn main() {
.action(action)
.flag(
Flag::new("bye", FlagType::Bool)
.usage("single_app args --bye(-b)")
.description("single_app args --bye(-b)")
.alias("b"),
);

Expand Down
Loading

0 comments on commit 8963ae3

Please sign in to comment.