This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.go
87 lines (70 loc) · 1.62 KB
/
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
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
78
79
80
81
82
83
84
85
86
87
package main
import (
"github.com/urfave/cli/v2"
)
var (
SoftVersion string
SoftVersionCode string
SoftBuildTime string
SoftCommit string
Tags string
// Config file (GMakefile)
e string = "G.toml"
)
var VersionInfo = Sprintf(`GMake2 is distributed under Mozilla Public License 2.0.
Github: https://github.com/3JoB/gmake2
Version: %v (%v)
Built on: %v
CommitID: %v`, SoftVersion, SoftVersionCode, SoftBuildTime, SoftCommit)
var InitFileContent = `config:
default: all
proxy:
req: false
vars:
msg: GMake2
all: |
@echo Hello! {{.msg}}!`
// User-Agent
var UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.52 GMake2/" + SoftVersion
var CliFlag = []cli.Flag{
CliFlagConfig,
CliFlagTags,
CliFlagDebug,
}
var CliCommands = []*cli.Command{
CliCommandInit,
CliCommandVersion,
}
var CliFlagDebug = &cli.BoolFlag{
Name: "debug",
Value: false,
Usage: "debug mode",
}
var CliFlagConfig = &cli.StringFlag{
Name: "config",
Aliases: []string{"c"},
Value: e,
Usage: "gmake2 Config File",
}
var CliFlagTags = &cli.StringFlag{
Name: "tag",
Hidden: true,
Aliases: []string{"t"},
Value: Tags,
Usage: "gmake2 Config File",
}
var CliCommandVersion = &cli.Command{
Name: "version",
Aliases: []string{"v"},
Usage: "gmake2 Version",
Action: func(ctx *cli.Context) error {
Println(VersionInfo)
return nil
},
}
var CliCommandInit = &cli.Command{
Name: "init",
Usage: "Initialize in the current directory.",
Action: InitFile,
}
var Error_Invalid error = Errors("invalid operator")