Skip to content

Commit

Permalink
Fix unhandled help command
Browse files Browse the repository at this point in the history
  • Loading branch information
loicsapone committed Nov 15, 2021
1 parent e5a5a7f commit ac50071
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ func Execute(version string) {
},
}

expandedArgs := []string{}
if len(os.Args) > 0 {
expandedArgs = os.Args[1:]
}

// translate `ae help <command>` to `ae <command> --help
if len(expandedArgs) == 2 && expandedArgs[0] == "help" {
expandedArgs = []string{expandedArgs[1], "--help"}
}

rootCmd.SetArgs(expandedArgs)

rootCmd.PersistentFlags().Bool("help", false, "Show help for command")
rootCmd.SetHelpFunc(helpCmd.Format)
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
Expand Down

0 comments on commit ac50071

Please sign in to comment.