aboutsummaryrefslogtreecommitdiffstats
path: root/commands/commands.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-16 22:38:52 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-16 22:38:52 +0200
commit451c3b30ca4f4b009509dffbe9c98a4c3b7ffeb0 (patch)
treeeec363eb6cc839bc7d09be532dd0fe8f155a1234 /commands/commands.go
parentead4511250deb877e1867c2e38cbee9c27deb299 (diff)
downloadgit-bug-451c3b30ca4f4b009509dffbe9c98a4c3b7ffeb0.tar.gz
commands: sort commands by name
Diffstat (limited to 'commands/commands.go')
-rw-r--r--commands/commands.go15
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