/
main.go
79 lines (60 loc) · 1.13 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
77
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"log"
"os"
)
var app = cli.NewApp()
func info() {
app.Name = "Clean Eagle Resources"
app.Usage = "Sometimes eagle resources not match *.json in folder, this tools will help fix it."
app.Authors = []*cli.Author{{
"ZHAOCHUNQI", "zcq.qiqi@gmail.com",
}}
app.Version = "1.0.0"
}
func commands() {
}
func options(){
app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "dryrun",
Usage: "Running programme with dryrun.",
Value: false,
DefaultText: "false",
},
&cli.StringFlag{
Name: "file",
Aliases: []string{"f"},
Required: true,
Value: "file",
Usage: "File path this commands will run." ,
},
}
}
func actions() {
app.Action = func(context *cli.Context) error {
var output string
dryRunMode := context.Bool("dryrun")
if dryRunMode{
output = "Working in DryRun mode"
fmt.Println(output)
}
if len(context.String("file"))!=0 {
path:= context.String("file")
FixImagePath(path, dryRunMode)
}
return nil
}
}
func main() {
info()
commands()
options()
actions()
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}