Skip to content

Commit

Permalink
Merge pull request google#106 from aminya/help-short-alias
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Jan 9, 2023
2 parents 728d143 + edc0191 commit 663a9ed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Options:
-j, --jump whether or not to jump
--height how high to go
--pilot-nickname an optional nickname for the pilot
--help display usage information
-h, --help display usage information
```

The resulting program can then be used in any of these ways:
Expand Down
8 changes: 4 additions & 4 deletions argh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub trait FromArgs: Sized {
/// Command to manage a classroom.
///
/// Options:
/// --help display usage information
/// -h, --help display usage information
///
/// Commands:
/// list list all the classes.
Expand All @@ -426,7 +426,7 @@ pub trait FromArgs: Sized {
///
/// Options:
/// --teacher-name list classes for only this teacher.
/// --help display usage information
/// -h, --help display usage information
/// "#.to_string(),
/// status: Ok(()),
/// },
Expand Down Expand Up @@ -568,7 +568,7 @@ pub trait FromArgs: Sized {
/// Command to manage a classroom.
///
/// Options:
/// --help display usage information
/// -h, --help display usage information
///
/// Commands:
/// list list all the classes.
Expand Down Expand Up @@ -885,7 +885,7 @@ pub fn parse_struct_args(

'parse_args: while let Some(&next_arg) = remaining_args.first() {
remaining_args = &remaining_args[1..];
if (next_arg == "--help" || next_arg == "help") && !options_ended {
if (next_arg == "--help" || next_arg == "help" || next_arg == "-h") && !options_ended {
help = true;
continue;
}
Expand Down
24 changes: 12 additions & 12 deletions argh/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Short description
Options:
--s a switch with a description that is spread across a number
of lines of comments.
--help display usage information
-h, --help display usage information
"###,
);
}
Expand Down Expand Up @@ -393,7 +393,7 @@ Woot
Options:
-n, --n fooey
--help display usage information
-h, --help display usage information
"###,
);
}
Expand All @@ -415,7 +415,7 @@ Woot
Options:
--option-name fooey
--help display usage information
-h, --help display usage information
"###,
);
}
Expand Down Expand Up @@ -453,7 +453,7 @@ Positional Arguments:
b fooey
Options:
--help display usage information
-h, --help display usage information
"###,
);
}
Expand Down Expand Up @@ -537,7 +537,7 @@ Positional Arguments:
Options:
--b woo
--c stuff
--help display usage information
-h, --help display usage information
"###,
);
}
Expand Down Expand Up @@ -946,7 +946,7 @@ mod fuchsia_commandline_tools_rubric {
A type for testing `--help`/`help`
Options:
--help display usage information
-h, --help display usage information
Commands:
first First subcommmand for testing `help`.
Expand All @@ -957,7 +957,7 @@ Commands:
First subcommmand for testing `help`.
Options:
--help display usage information
-h, --help display usage information
Commands:
second Second subcommand for testing `help`.
Expand All @@ -968,7 +968,7 @@ Commands:
Second subcommand for testing `help`.
Options:
--help display usage information
-h, --help display usage information
"###;

#[test]
Expand Down Expand Up @@ -1149,7 +1149,7 @@ Options:
documentation
-s, --scribble write <scribble> repeatedly
-v, --verbose say more. Defaults to $BLAST_VERBOSE.
--help display usage information
-h, --help display usage information
Commands:
blow-up explosively separate
Expand Down Expand Up @@ -1189,7 +1189,7 @@ Positional Arguments:
name
Options:
--help display usage information
-h, --help display usage information
"###,
);
}
Expand Down Expand Up @@ -1219,7 +1219,7 @@ Positional Arguments:
two this one is real
Options:
--help display usage information
-h, --help display usage information
"###,
);
}
Expand Down Expand Up @@ -1582,7 +1582,7 @@ Woot
Options:
-n, --n fooey
--help display usage information
-h, --help display usage information
"###
.to_owned(),
status: Ok(()),
Expand Down
2 changes: 1 addition & 1 deletion argh_derive/src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub(crate) fn help(
option_description(errors, &mut format_lit, option);
}
// Also include "help"
option_description_format(&mut format_lit, None, "--help", "display usage information");
option_description_format(&mut format_lit, None, "-h, --help", "display usage information");

let subcommand_calculation;
let subcommand_format_arg;
Expand Down

0 comments on commit 663a9ed

Please sign in to comment.