-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
76 lines (61 loc) · 1.36 KB
/
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
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
package main
import (
"os"
"github.com/urfave/cli/v2"
)
var pretty bool
var flagFile, flagPath, flagDelimiter cli.StringFlag
var flagMultiKey, flagMultiValue cli.StringSliceFlag
var flagDebug, flagPretty, flagExists cli.BoolFlag
func init() {
flagFile = cli.StringFlag{
Name: "file,f",
Usage: "the file to edit. stdin if not specified.",
}
flagPath = cli.StringFlag{
Name: "path,p",
Usage: "the path to the data being acted upon.",
}
flagDelimiter = cli.StringFlag{
Name: "delimiter,d",
Usage: "the path delimiter",
}
flagMultiKey = cli.StringSliceFlag{
Name: "key,k",
Usage: "the key to set. can be used multiple times.",
}
flagMultiValue = cli.StringSliceFlag{
Name: "value,v",
Usage: "the value to set. can be used multiple times.",
}
flagDebug = cli.BoolFlag{
Name: "debug,d",
Usage: "debug mode",
Destination: &debugMode,
}
flagPretty = cli.BoolFlag{
Name: "pretty,r",
Usage: "pretty print the result.",
Destination: &pretty,
}
flagExists = cli.BoolFlag{
Name: "exists,e",
Usage: "don't insert if value already exists",
}
}
func main() {
app := cli.NewApp()
app.Name = "jsed"
app.Usage = "a simple json utility"
app.Version = "0.3.0"
app.Flags = []cli.Flag{
&flagDebug,
}
app.Commands = []*cli.Command{
&cmdGet,
&cmdContains,
&cmdAdd,
&cmdDel,
}
app.Run(os.Args)
}