-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflags.go
109 lines (98 loc) · 2.81 KB
/
flags.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
package main
import (
"github.com/urfave/cli/v2"
)
const (
flagSource = "source" // serial, file, demo
flagSerialPort = "serial-port" // serial port name
flagHttpPort = "http-port" // http port number
flagLogFile = "log-file" // log file path
flagLogFrom = "log-from" // log from datetime: YYYY/MM/DD HH:mm:SS.SSSSSS
flagLogSocket = "log-socket" // log socket messages
flagDemoSpeed = "demo-speed" // avg events per minute
flagLocale = "locale"
flagSpeakCommand = "speak"
flagSpeakLives = "speak-lives"
flagSpeakCheers = "speak-cheers"
)
const (
defaultLogFilePath = "fpvc-lady.log"
)
func getFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: flagSource,
Usage: "Source of CSP messages: serial, log, demo.",
EnvVars: []string{"SOURCE"},
Required: false,
Value: "serial",
},
&cli.StringFlag{
Name: flagSerialPort,
Usage: "Port name where HC12 is connected to; by default the system will try find the port automatically.",
EnvVars: []string{"SERIAL_PORT"},
Required: false,
Value: "auto",
},
&cli.IntFlag{
Name: flagHttpPort,
Usage: "HTTP server port number",
EnvVars: []string{"HTTP_PORT"},
Value: 8080,
},
&cli.StringFlag{
Name: flagLogFile,
Usage: "Path to the log file: save events to (when --source=serial) or read events from (when --source=log).",
EnvVars: []string{"LOG_FILE"},
Required: false,
Value: defaultLogFilePath,
},
&cli.StringFlag{
Name: flagLogSocket,
Usage: "File path to log web socket communication.",
EnvVars: []string{"LOG_SOCKET"},
Required: false,
Value: "",
},
&cli.StringFlag{
Name: flagLogFrom,
Usage: "Datetime to start read events from. Format: YYYY/MM/DD[ HH:mm:SS[.SSSSSS]]",
EnvVars: []string{"LOG_FROM"},
Required: false,
Value: "",
},
&cli.IntFlag{
Name: flagDemoSpeed,
Usage: "Number of hits, in average, per minute",
EnvVars: []string{"DEMO_SPEED"},
Value: 10, // 10 is good speed for demo to end soon and all phrases to be spoken; 20 simulates very intence combat, speaker may have to drop phrases
},
&cli.StringFlag{
Name: flagLocale,
Usage: "Locale to use: de, en, ru, etc.",
Required: false,
Value: "en",
},
&cli.StringFlag{
Name: flagSpeakCommand,
Usage: "Text-to-speech command: system, google, none or any other command to convert text to speech.",
EnvVars: []string{"SPEAK"},
Required: false,
Value: "system",
},
&cli.BoolFlag{
Name: flagSpeakLives,
Usage: "Speak lives.",
EnvVars: []string{"SPEAK_LIVES"},
Required: false,
Value: false,
},
&cli.BoolFlag{
Name: flagSpeakCheers,
Usage: "Speak cheers.",
EnvVars: []string{"SPEAK_CHEERS"},
Required: false,
Value: false,
},
}
}