diff options
Diffstat (limited to 'commands/commands.go')
-rw-r--r-- | commands/commands.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/commands/commands.go b/commands/commands.go index 0a3c33ad..1e8e9e19 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "github.com/MichaelMure/git-bug/repository" + "sort" ) var commandsFlagSet = flag.NewFlagSet("commands", flag.ExitOnError) @@ -18,19 +19,29 @@ func runCommands(repo repository.Repo, args []string) error { first := true - for name, cmd := range CommandMap { + keys := make([]string, 0, len(CommandMap)) + + for key := range CommandMap { + keys = append(keys, key) + } + + sort.Strings(keys) + + for _, key := range keys { if !first { fmt.Println() } first = false + cmd := CommandMap[key] + if *commandsDesc { fmt.Printf("# %s\n", cmd.Description) } // TODO: the root name command ("git bug") should be passed from git-bug.go but well ... - fmt.Printf("%s %s %s\n", "git bug", name, cmd.Usage) + fmt.Printf("%s %s %s\n", "git bug", key, cmd.Usage) } return nil |