Skip to content

Commit

Permalink
test(parser): Verify subcommand required message
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 15, 2022
1 parent 010976c commit d21ee51
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/builder/app_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ fn sub_command_required() {
assert_eq!(err.kind(), ErrorKind::MissingSubcommand);
}

#[test]
#[cfg(feature = "error-context")]
fn sub_command_required_error() {
static ERROR: &str = "\
error: 'sc_required' requires a subcommand but one was not provided
Usage: sc_required <COMMAND>
For more information try '--help'
";

let cmd = Command::new("sc_required")
.subcommand_required(true)
.subcommand(Command::new("sub1"));
utils::assert_output(cmd, "sc_required", ERROR, true);
}

#[test]
fn arg_required_else_help() {
let result = Command::new("arg_required")
Expand Down

0 comments on commit d21ee51

Please sign in to comment.