-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.go
More file actions
68 lines (60 loc) · 1.23 KB
/
cli.go
File metadata and controls
68 lines (60 loc) · 1.23 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
cli "github.com/urfave/cli/v2"
)
// ServerCommand is the cli command that run the server
func ServerCommand() *cli.Command {
return &cli.Command{
Name: "server",
Aliases: []string{},
Usage: "Start the server",
Action: func(c *cli.Context) error {
RunServer()
return nil
},
}
}
// UpCommand is the cli command for counting up
func UpCommand() *cli.Command {
return &cli.Command{
Name: "up",
Aliases: []string{"u"},
Usage: "Count up to stop value.",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "stop",
Aliases: []string{"s"},
Value: 10,
},
},
Action: func(c *cli.Context) error {
stop := c.Int("stop")
res, err := MakeUpRequest(stop)
FatalOnErr(err)
Logger.Info(res)
return nil
},
}
}
// DownCommand is the cli command for counting down
func DownCommand() *cli.Command {
return &cli.Command{
Name: "down",
Aliases: []string{"d"},
Usage: "Count down from value",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "start",
Aliases: []string{"s"},
Value: 10,
},
},
Action: func(c *cli.Context) error {
start := c.Int("start")
res, err := MakeDownRequest(start)
FatalOnErr(err)
Logger.Info(res)
return err
},
}
}