generated from andrewarrow/infinity-dog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.go
41 lines (37 loc) · 708 Bytes
/
cli.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
package main
import (
"fmt"
"os"
"strings"
)
func PrintHelp() {
fmt.Println("")
fmt.Println(" ack run")
fmt.Println(" ack credits")
fmt.Println(" ack transfer")
fmt.Println(" ack help")
fmt.Println("")
}
func ArgsToMap() map[string]string {
m := map[string]string{}
if len(os.Args) == 1 {
return m
}
for _, a := range os.Args[1:] {
if strings.HasPrefix(a, "--") {
tokens := strings.Split(a, "=")
key := strings.Split(tokens[0], "--")
if len(tokens) == 2 {
m[key[1]] = tokens[1]
} else {
m[key[1]] = "true"
}
} else if strings.Contains(a, "=") {
tokens := strings.Split(a, "=")
if len(tokens) == 2 {
m[tokens[0]] = tokens[1]
}
}
}
return m
}