-
Notifications
You must be signed in to change notification settings - Fork 8
/
commands.go
118 lines (92 loc) · 2.4 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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package main
import (
"fmt"
"log"
"github.com/GrupaPracuj/iislog-prometheus-exporter/config"
"github.com/GrupaPracuj/iislog-prometheus-exporter/discovery"
"github.com/GrupaPracuj/iislog-prometheus-exporter/service"
)
type versionCommand struct {
version string
}
type debugCommand struct {
serviceName string
config *config.Config
logger *log.Logger
}
type installCommand struct {
serviceName string
}
type removeCommand struct {
serviceName string
config *config.Config
logger *log.Logger
}
type daemonCommand struct {
config *config.Config
logger *log.Logger
}
type checkConfigCommand struct{}
func (c *versionCommand) Run(_ []string) int {
fmt.Printf("%v\r\n", c.version)
return 0
}
func (c *versionCommand) Help() string {
return "Display IISLogExporter version"
}
func (c *versionCommand) Synopsis() string {
return "Display version"
}
func (c *debugCommand) Run(_ []string) int {
service.Run(c.serviceName, true, c.config, c.logger)
return 0
}
func (c *debugCommand) Help() string {
return "Debug IISLogExporter"
}
func (c *debugCommand) Synopsis() string {
return "Debug IISLogExporter"
}
func (c *installCommand) Run(_ []string) int {
service.Install(c.serviceName)
fmt.Printf("install command succeded\r\n")
return 0
}
func (c *installCommand) Help() string {
return "Install IISLogExporter as Windows Service"
}
func (c *installCommand) Synopsis() string {
return "Install IISLogExporter as Windows Service"
}
func (c *removeCommand) Run(_ []string) int {
discovery.DeregisterFromConsul(c.config, c.logger)
service.Remove(c.serviceName)
fmt.Printf("remove command succeded\r\n")
return 0
}
func (c *removeCommand) Help() string {
return "Remove IISLogExporter from Windows Services"
}
func (c *removeCommand) Synopsis() string {
return "Remove IISLogExporter from Windows Services"
}
func (c *daemonCommand) Run(_ []string) int {
service.Run(defaultServiceName, false, c.config, c.logger)
return 0
}
func (c *daemonCommand) Help() string {
return "Run IISLogExporter as daemon"
}
func (c *daemonCommand) Synopsis() string {
return "Run IISLogExporter as daemon"
}
func (c *checkConfigCommand) Run(_ []string) int {
fmt.Printf("Configuration file is valid")
return 0
}
func (c *checkConfigCommand) Help() string {
return "Check if configuration file is valid"
}
func (c *checkConfigCommand) Synopsis() string {
return "Check if configuration file is valid"
}