@@ 27,6 27,7 @@ package main
import (
"fmt"
"os"
+ "sort"
"strconv"
"strings"
@@ 54,6 55,15 @@ var baseCmd = &cobra.Command{
Short: "Alternate low-level ceph cli experimentation tool",
}
+func sortCmds(cmds desc.Commands) desc.Commands {
+ sort.Slice(cmds, func(i, j int) bool {
+ a := strings.Join(cmds[i].PrefixArgs(), " ")
+ b := strings.Join(cmds[j].PrefixArgs(), " ")
+ return a < b
+ })
+ return cmds
+}
+
func listCmdHelp(cmds desc.Commands) {
fmt.Printf("--- found %d possible commands ---\n", len(cmds))
var filter bool
@@ 219,7 229,7 @@ func subCommand(cr runner.Runner, args [
return err
}
if len(args) == 0 {
- listCmdHelp(cmds)
+ listCmdHelp(sortCmds(cmds))
return nil
}
cmd, similarCmds := desc.Match(cmds, args)
@@ 227,7 237,7 @@ func subCommand(cr runner.Runner, args [
if len(similarCmds) == 0 {
return fmt.Errorf("no commands matching: %s", strings.Join(args, " "))
}
- listCmdHelp(similarCmds)
+ listCmdHelp(sortCmds(similarCmds))
return nil
}
if commandHelp {