Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1 - Sort (new) commands in alphabetical order. #10

Merged
merged 1 commit into from
Dec 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ahoy/ahoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"gopkg.in/yaml.v2"
"io/ioutil"
"sort"
"strings"
)

Expand Down Expand Up @@ -65,14 +66,21 @@ func getConfig(sourcefile string) (Config, error) {

func getCommands(config Config) []cli.Command {
exportCmds := []cli.Command{}
for name, cmd := range config.Commands {
cmdCopy := cmd.Cmd

var keys []string
for k := range config.Commands {
keys = append(keys, k)
}
sort.Strings(keys)

for _ , name := range keys {
cmd := config.Commands[name]
newCmd := cli.Command{
Name: name,
Usage: cmd.Usage,
Action: func(c *cli.Context) {
args = c.Args()
runCommand(cmdCopy);
runCommand(cmd.Cmd);
},
}
//log.Println("found command: ", name, " > ", cmd.Cmd )
Expand Down