Skip to content

Commit

Permalink
Merge pull request #11953 from markusthoemmes/help-default
Browse files Browse the repository at this point in the history
Display help text on empty subcommand by default
  • Loading branch information
openshift-merge-robot authored Nov 8, 2021
2 parents 22ef488 + 756dda2 commit abfec81
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cmd/podman/validate/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func SubCommandExists(cmd *cobra.Command, args []string) error {
}
return errors.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t"))
}
return errors.Errorf("missing command '%[1]s COMMAND'\nTry '%[1]s --help' for more information.", cmd.CommandPath())
cmd.Help()
return errors.Errorf("missing command '%[1]s COMMAND'", cmd.CommandPath())
}

// IDOrLatestArgs used to validate a nameOrId was provided or the "--latest" flag
Expand Down
4 changes: 1 addition & 3 deletions test/system/001-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ function setup() {
fi

run_podman 125 --remote
is "$output" "Error: missing command 'podman COMMAND'
Try 'podman --help' for more information." \
"podman --remote show usage message without running endpoint"
is "$output" ".*Usage:" "podman --remote show usage message without running endpoint"
}

# This is for development only; it's intended to make sure our timeout
Expand Down
4 changes: 2 additions & 2 deletions test/system/015-help.bats
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ function check_help() {
count=$(expr $count + 1)
done

# Any command that takes subcommands, must throw error if called
# Any command that takes subcommands, prints its help and errors if called
# without one.
dprint "podman $@"
run_podman '?' "$@"
is "$status" 125 "'podman $*' without any subcommand - exit status"
is "$output" "Error: missing command .*$@ COMMAND" \
is "$output" ".*Usage:.*Error: missing command '.*$@ COMMAND'" \
"'podman $*' without any subcommand - expected error message"

# Assume that 'NoSuchCommand' is not a command
Expand Down

0 comments on commit abfec81

Please sign in to comment.