Skip to content

Commit a51c81d

Browse files
authored
chore: capitalize all help commands (#16)
1 parent 3790d37 commit a51c81d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎cmd/root.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,24 @@ var rootCmd = &cobra.Command{
2020
SilenceUsage: true,
2121
}
2222

23+
func fixHelpFlags(cmd *cobra.Command) {
24+
cmd.InitDefaultHelpFlag()
25+
if f := cmd.Flags().Lookup("help"); f != nil {
26+
name := cmd.Name()
27+
if name == "" {
28+
name = "this command"
29+
}
30+
f.Usage = "Help for " + name
31+
}
32+
for _, sub := range cmd.Commands() {
33+
fixHelpFlags(sub)
34+
}
35+
}
36+
2337
// Execute adds all child commands to the root command and sets flags appropriately.
2438
// This is called by main.main(). It only needs to happen once to the rootCmd.
2539
func Execute() {
40+
fixHelpFlags(rootCmd)
2641
err := rootCmd.Execute()
2742
if err != nil {
2843
if isJSONOutput() {

0 commit comments

Comments
 (0)