/
signal_list.go
54 lines (43 loc) · 995 Bytes
/
signal_list.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
44
45
46
47
48
49
50
51
52
53
54
package commands
import (
"fmt"
"github.com/chroju/nature-remo-cli/configfile"
"github.com/mitchellh/cli"
)
type SignalListCommand struct {
UI cli.Ui
}
func (c *SignalListCommand) Run(args []string) int {
if len(args) != 0 {
c.UI.Warn(fmt.Sprintf("%s\n\ncommand \"signal list\" does not expect any args", helpSignalList))
return 1
}
path, err := configfile.GetConfigFilePath()
if err != nil {
c.UI.Error(err.Error())
return 2
}
con, err := configfile.New(path)
if err != nil {
c.UI.Error(err.Error())
return 2
}
appliances, err := con.LoadAppliances()
if err != nil {
c.UI.Error(err.Error())
return 2
}
for _, a := range appliances {
for _, s := range a.Signals {
c.UI.Output(fmt.Sprintf("%s %s", a.Name, s.Name))
}
}
return 0
}
func (c *SignalListCommand) Help() string {
return helpSignalList
}
func (c *SignalListCommand) Synopsis() string {
return "Show all appliance and signal names"
}
const helpSignalList = "Usage: remo signal list"