-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflag.go
41 lines (35 loc) · 1.12 KB
/
flag.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 (
"flag"
"fmt"
"os"
)
type parameters struct {
//生成模式
mode string
//额外参数
extra string
//source模板生成
genSource string
//自定义配置路径
confFile string
//使用帮助
help bool
//版本信息
version bool
}
var params *parameters
func init() {
params = new(parameters)
flag.StringVar(¶ms.mode, "m", "", `export data by source config <lua|json|cs_proto>, example [ -m lua ] or [ -m lua|json ] `)
flag.StringVar(¶ms.extra, "e", "", `export data extra arg example <arg1=value1|arg2=value2|value3>`)
flag.StringVar(¶ms.genSource, "g", "", `generator source template <target_name,excel_name,sheet_name> or <target_name,csv_name>, example [ -g base_test,base_test.xlsx,Sheet1 ]`)
flag.BoolVar(¶ms.help, "help", false, "this help")
flag.BoolVar(¶ms.version, "version", false, "this version")
flag.StringVar(¶ms.confFile, "conf", "conf/config.toml", "use custom config.toml filepath,default is conf/config.toml")
}
func usage() {
fmt.Fprintf(os.Stderr, `Usage: table-export [-m <mode>] [-f <target_name,excel_name,sheet_name>]
`)
flag.PrintDefaults()
}