-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
45 lines (35 loc) · 632 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
44
45
package main
import (
"os"
"strings"
)
var running = true
func main() {
args := os.Args
if len(args) < 2 {
printUsage()
return
}
_, command := parseArguments(args)
switch command[0] {
case "help":
printHelp()
case "ls", "list":
prettyPrintListCards(command)
case "pls", "plainlist":
plainPrintListCards(command)
case "set":
setFan(command)
}
}
func parseArguments(args []string) (string, []string) {
var options string
var command []string
if strings.Contains(args[1], "-") && len(args) > 2 {
options = args[1]
command = args[2:]
} else {
command = args[1:]
}
return options, command
}