forked from 89luca89/transactional-update-notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (33 loc) · 810 Bytes
/
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
// main package
package main
import (
"fmt"
"os"
)
// Version is the current value injected at build time.
var Version string
// Message is the standard message that client and daemon should exchange to trigger a notify.
var Message = "org.transactionalUpdate.Notify"
func main() {
if len(os.Args) < 2 || os.Args[1] == "-h" || os.Args[1] == "--help" {
fmt.Fprintf(os.Stderr, "usage: %s transactional-update-notifier [daemon|client]\n", os.Args[0])
return
}
// Version flag
if os.Args[1] == "-v" || os.Args[1] == "version" {
fmt.Println(Version)
return
}
if os.Args[1] == "daemon" {
NotifyDaemon()
return
}
if os.Args[1] == "client" {
if len(os.Args) > 2 && os.Args[2] == "failure" {
NotifyDaemonClient("failure")
return
}
NotifyDaemonClient("success")
return
}
}