-
Notifications
You must be signed in to change notification settings - Fork 24
/
commands.go
43 lines (40 loc) · 1.02 KB
/
commands.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
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"github.com/fatih/color"
"github.com/urfave/cli"
)
func setCommands(app *cli.App) {
app.Commands = []cli.Command{
{
Name: "new",
Aliases: []string{"c"},
Usage: "Create a new ADR",
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
currentConfig := getConfig()
currentConfig.CurrentAdr++
updateConfig(currentConfig)
newAdr(currentConfig, c.Args())
return nil
},
},
{
Name: "init",
Aliases: []string{"i"},
Usage: "Initializes the ADR configurations",
UsageText: "adr init /home/user/adrs",
Description: "Initializes the ADR configuration with an optional ADR base directory\n This is a a prerequisite to running any other adr sub-command",
Action: func(c *cli.Context) error {
initDir := c.Args().First()
if initDir == "" {
initDir = adrDefaultBaseFolder
}
color.Green("Initializing ADR base at " + initDir)
initBaseDir(initDir)
initConfig(initDir)
initTemplate()
return nil
},
},
}
}