mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-04 20:51:44 +00:00
Exit with non-zero code on first argument parsing error
Ignoring return value of ParseFlags leads to exit code 0 if bad arguments are supplied. This patch makes sure that subcommands exit with non-zero code in such a case. Signed-off-by: Michal Minar <miminar@redhat.com>
This commit is contained in:
+4
-1
@@ -8,7 +8,10 @@ import (
|
||||
)
|
||||
|
||||
// ParseFlags is a utility function that adds a help flag if withHelp is true,
|
||||
// calls cmd.Parse(args) and prints a relevant error message if there are incorrect number of arguments.
|
||||
// calls cmd.Parse(args) and prints a relevant error message if there are
|
||||
// incorrect number of arguments. It returns error only if error handling is
|
||||
// set to ContinueOnError and parsing fails. If error handling is set to
|
||||
// ExitOnError, it's safe to ignore the return value.
|
||||
// TODO: move this to a better package than utils
|
||||
func ParseFlags(cmd *flag.FlagSet, args []string, withHelp bool) error {
|
||||
var help *bool
|
||||
|
||||
Reference in New Issue
Block a user