diff --git a/Cargo.toml b/Cargo.toml index ca067cb..41ff949 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "seahorse" -version = "1.1.0" +version = "1.1.1" authors = ["ksk001100 "] edition = "2018" keywords = [ diff --git a/README.md b/README.md index f10af2d..18b0884 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To use seahorse, add this to your Cargo.toml: ```toml [dependencies] -seahorse = "1.1.0" +seahorse = "1.1" ``` ## Example diff --git a/examples/multiple_app.rs b/examples/multiple_app.rs index bb09996..78c8fae 100644 --- a/examples/multiple_app.rs +++ b/examples/multiple_app.rs @@ -54,8 +54,8 @@ fn hello_command() -> Command { Command::new("hello") .description("hello command") .usage("multiple_app hello(he, h) [name]") - .alias("he") .alias("h") + .alias("he") .action(hello_action) .flag( Flag::new("bye", FlagType::Bool) diff --git a/src/app.rs b/src/app.rs index 95453e6..d22a27e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -333,10 +333,24 @@ impl App { if let Some(commands) = &self.commands { text += "\nCommands:\n"; - let name_max_len = &commands.iter().map(|c| c.name.len()).max().unwrap(); + let name_max_len = &commands + .iter() + .map(|c| { + if let Some(alias) = &c.alias { + format!("{}, {}", alias.join(", "), c.name).len() + } else { + c.name.len() + } + }) + .max() + .unwrap(); for c in commands { - let command_name_len = c.name.len(); + let command_name = if let Some(alias) = &c.alias { + format!("{}, {}", alias.join(", "), c.name) + } else { + c.name.clone() + }; let description = match &c.description { Some(description) => description, @@ -345,8 +359,8 @@ impl App { text += &format!( "\t{} {}: {}\n", - c.name, - " ".repeat(name_max_len - command_name_len), + command_name, + " ".repeat(name_max_len - command_name.len()), description ); }