/
main.go
52 lines (49 loc) · 1.42 KB
/
main.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
package main
import (
"github.com/GochoMugo/argparse"
"github.com/GochoMugo/go-out"
)
const pushdName = "pushd"
const pushdDecription = "A pushbullet daemon"
const pushdVersion = "0.0.0"
const pushdHomepage = "https://github.com/GochoMugo/pushd"
func main() {
program := argparse.New()
program.Description(pushdName, pushdDecription)
program.Version(pushdVersion)
program.Epilog("See " + pushdHomepage + " for feature requests and bug reports")
program.Command("s", "start", "start daemon", func(a argparse.Args) {
out.Info("starting daemon")
d := new(Daemon)
d.Port = a.AsString("port", "p")
d.Start()
})
program.Command("x", "stop", "stop daemon", func(a argparse.Args) {
out.Info("stopping daemon")
res, err := StopDaemon(a.AsString("port", "p"))
if err != nil {
out.Error("errored: %s", err)
return
}
out.Info("response: %s", res)
})
program.Command("?", "status", "check status", func(a argparse.Args) {
out.Info("checking daemon status")
res, err := CheckDaemonStatus(a.AsString("port", "p"))
if err != nil {
out.Error("errored: %s", err)
return
}
out.Info("response: %s", res)
})
program.Command("n", "notify", "push notification", func(a argparse.Args) {
out.Info("sending notification")
res, err := SendNotification(a.AsString("port", "p"), a.AsString("message", "m"))
if err != nil {
out.Error("errored: %s", err)
return
}
out.Info("response: %s", res)
})
program.Parse()
}