Skip to content

Commit

Permalink
cmd: display help menu when no args are passed in - skip the error
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Deza <adeza@anchore.com>
  • Loading branch information
Alfredo Deza committed Aug 3, 2020
1 parent 87e6dc0 commit c581a45
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var rootCmd = &cobra.Command{
`, map[string]interface{}{
"appName": internal.ApplicationName,
}),
Args: cobra.ExactArgs(1),
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if appConfig.Dev.ProfileCPU {
f, err := os.Create("cpu.profile")
Expand All @@ -49,7 +49,14 @@ var rootCmd = &cobra.Command{
}
}
}

if len(args) == 0 {
err := cmd.Help()
if err != nil {
log.Errorf(err.Error())
os.Exit(1)
}
os.Exit(1)
}
err := runDefaultCmd(cmd, args)

if appConfig.Dev.ProfileCPU {
Expand Down

0 comments on commit c581a45

Please sign in to comment.