-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (53 loc) · 1.08 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
package main
import (
"fmt"
"log"
"os"
"sort"
defaultjson "JsonParse/default"
jsonuse "JsonParse/json"
"github.com/urfave/cli"
)
func defaultRun(c *cli.Context) error {
defaultjson.DefaultJson(location)
return nil
}
func jsonRun(c *cli.Context) error {
jsonuse.Jsonuse(location)
return nil
}
var location string
func main() {
fmt.Println("-----start:----")
//Start
app := cli.NewApp()
app.Name = "Json Parser"
app.Usage = "Json Parser v1"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "from, f",
Usage: "input the location of the files",
Destination: &location,
},
}
app.Commands = []cli.Command{
{
Name: "jsonRun",
Aliases: []string{"j"},
Usage: "run script to output summary excel from json files",
Action: jsonRun,
},
{
Name: "defaultRun",
Aliases: []string{"d"},
Usage: "run script to output summary excel from default files",
Action: defaultRun,
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
err := app.Run(os.Args)
if err != nil {
log.Fatalln(err)
}
}