File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ {{define "type_struct" -}}
2+
3+ // The {{.typeName}} type defines all the configurable options from cli.
4+ type {{.typeName}} struct { {{- range .Options}}
5+ {{- if eq .Name "Args" }}
6+
7+ {{.Args}}
8+ {{- else }}{{$f := stringsSplit .Flag ","}}{{ $flen := len $f }}
9+ {{.Name}} {{.Type}} `short:"{{index $f 0}}"{{if gt $flen 1}} long:"{{index $f 1}}"{{end}}{{if .EnvV}} env:"{{printf "%s_%s" (clk2ss $.ProgramName) (clk2ss .Name)}}"{{end}} description:"{{.Usage}}"{{if .Value}} default:"{{.Value}}"{{end}}`{{end}}
10+ {{- end}}
11+ {{- if .Verbose}}
12+ Verbflg func() `short:"v" long:"verbose" description:"Verbose mode (Multiple -v options increase the verbosity)"`
13+ Verbose uint
14+ {{end}}
15+ {{- end -}}
16+
17+ {{range .Command}}
18+ ////////////////////////////////////////////////////////////////////////////
19+ // {{.Name}}
20+
21+ {{template "type_struct" argsm "Options" .Options "typeName" (print (stringsTitle .Name) "Command") }}
22+ }
23+ {{end}}
Original file line number Diff line number Diff line change 1+ Command :
2+
3+ - Name : publish
4+ Desc : " Publish application"
5+ Text : ' Publish the network application"'
6+
7+ Options :
8+ - Name : Dir
9+ Type : string
10+ Flag : ' *d,dir'
11+ Usage : publish dir
12+
13+ - Name : Suffix
14+ Type : string
15+ Flag : suffix
16+ Value : " .go,.c,.s"
17+ Usage : " source file suffix"
18+
19+ - Name : Out
20+ Type : string
21+ Flag : o,out
22+ Usage : " output filename"
23+
24+ - Name : List
25+ Type : bool
26+ Flag : l,list
27+ Usage : " list all sub commands"
28+
29+ - Name : Args
30+ Args : |
31+ // Example of positional arguments
32+ Args struct {
33+ ID string
34+ Num int
35+ Rest []string
36+ "} `positional-args:"yes" required:"yes"`"
You can’t perform that action at this time.
0 commit comments