forked from pkallberg/cx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases.go
32 lines (28 loc) · 846 Bytes
/
aliases.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import "fmt"
func populateAliases(commands []*Command) []*Command {
aliasMap := make(map[string][]string)
aliasMap["backups"] = []string{"backup"}
aliasMap["containers"] = []string{"container"}
aliasMap["databases"] = []string{"database"}
aliasMap["servers"] = []string{"server"}
aliasMap["services"] = []string{"service"}
aliasMap["settings"] = []string{"setting"}
aliasMap["stacks"] = []string{"stack"}
for key, aliases := range aliasMap {
for _, command := range commands {
if command.Name == key {
for _, alias := range aliases {
var newCmd = &Command{
NeedsStack: command.NeedsStack,
Name: alias,
Build: command.Build,
Short: fmt.Sprintf("[%s alias] %s", key, command.Short),
}
commands = append(commands, newCmd)
}
}
}
}
return commands
}