@@ -73,27 +73,8 @@ var rootCmd = &cobra.Command{
7373 Long : `Deploy machine learning models in production` ,
7474}
7575
76- // Copied from https://github.com/spf13/cobra/blob/master/command.go, in order to make the short descritpion start with lower case
77- var helpCmd = & cobra.Command {
78- Use : "help [command]" ,
79- Short : "help about any command" ,
80- Long : `help provides help for any command in the CLI.
81- Type ` + rootCmd .Name () + ` help [path to command] for full details.` ,
82- Run : func (c * cobra.Command , args []string ) {
83- cmd , _ , e := c .Root ().Find (args )
84- if cmd == nil || e != nil {
85- c .Printf ("Unknown help topic %#q\n " , args )
86- c .Root ().Usage ()
87- } else {
88- cmd .InitDefaultHelpFlag ()
89- cmd .Help ()
90- }
91- },
92- }
93-
9476func Execute () {
9577 defer errors .RecoverAndExit ()
96- rootCmd .SetHelpCommand (helpCmd )
9778
9879 cobra .EnableCommandSorting = false
9980
@@ -111,10 +92,33 @@ func Execute() {
11192 rootCmd .AddCommand (supportCmd )
11293 rootCmd .AddCommand (completionCmd )
11394
95+ updateRootUsage ()
96+
11497 printLeadingNewLine ()
11598 rootCmd .Execute ()
11699}
117100
101+ func updateRootUsage () {
102+ defaultUsageFunc := rootCmd .UsageFunc ()
103+ usage := rootCmd .UsageString ()
104+
105+ rootCmd .SetUsageFunc (func (cmd * cobra.Command ) error {
106+ if cmd .Use != "cortex" {
107+ return defaultUsageFunc (cmd )
108+ }
109+
110+ usage = strings .Replace (usage , "Usage:\n cortex [command]\n \n Aliases:\n cortex, cx\n \n " , "" , 1 )
111+ usage = strings .Replace (usage , "Available Commands:" , "Deployment Commands:" , 1 )
112+ usage = strings .Replace (usage , "\n cluster" , "\n \n Cluster commands:\n cluster" , 1 )
113+ usage = strings .Replace (usage , "\n configure" , "\n \n Other commands:\n configure" , 1 )
114+ usage = strings .Replace (usage , "\n Use \" cortex" , " help help about any command\n \n Flags:\n -h, --help help for cortex\n \n Use \" cortex" , 1 )
115+
116+ cmd .Print (usage )
117+
118+ return nil
119+ })
120+ }
121+
118122func printLeadingNewLine () {
119123 if len (os .Args ) == 2 && os .Args [1 ] == "completion" {
120124 return
0 commit comments