cmd: display help menu when no args are passed in - skip the error

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza 2020-08-03 12:02:44 -04:00
parent 87e6dc08ec
commit c581a454f2

View file

@ -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")
@ -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 {