Skip to content

Commit

Permalink
- [+] add Aliases support
Browse files Browse the repository at this point in the history
  • Loading branch information
suntong committed Feb 15, 2021
1 parent 9dd4fe3 commit ddd8500
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cli-ext.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ var {{.Name}}Def = &cli.Command{
Desc: "{{.Desc}}",
{{if .Text}} Text: "{{.Text}}"{{if .UsageLead}} +
"\n\n{{.UsageLead}}"{{end}},{{end}}
{{if .Self}} Argv: func() interface{} { t := new({{.Name}}T); t.Self = t; return t },
{{if .Aliases}} Aliases: []string{ {{.Aliases}} },
{{end}}{{if .Self}} Argv: func() interface{} { t := new({{.Name}}T); t.Self = t; return t },
{{else}} Argv: func() interface{} { return new({{.Name}}T) },
{{end}} Fn: {{.Name}}CLI,
{{if .NumOption}}
Expand Down
3 changes: 2 additions & 1 deletion cli-std.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ var {{.Name}}Def = &cli.Command{
Desc: "{{.Desc}}",
{{if .Text}} Text: "{{.Text}}"{{if .UsageLead}} +
"\n\n{{.UsageLead}}"{{end}},{{end}}
{{if .Self}} Argv: func() interface{} { t := new({{.Name}}T); t.Self = t; return t },
{{if .Aliases}} Aliases: []string{ {{.Aliases}} },
{{end}}{{if .Self}} Argv: func() interface{} { t := new({{.Name}}T); t.Self = t; return t },
{{else}} Argv: func() interface{} { return new({{.Name}}T) },
{{end}} Fn: {{.Name}}CLI,
{{if .NumOption}}
Expand Down
1 change: 1 addition & 0 deletions wireframe_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Command:
- Name: put
Desc: "Upload into service"
Text: 'Usage:\n wireframe put -i /tmp/f'
Aliases: '"up","upload"'
#NumArg: cli.AtLeast(1)
NumOption: cli.AtLeast(1)

Expand Down
11 changes: 6 additions & 5 deletions wireframe_cliDef.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ type putT struct {
}

var putDef = &cli.Command{
Name: "put",
Desc: "Upload into service",
Text: "Usage:\n wireframe put -i /tmp/f",
Argv: func() interface{} { return new(putT) },
Fn: putCLI,
Name: "put",
Desc: "Upload into service",
Text: "Usage:\n wireframe put -i /tmp/f",
Aliases: []string{"up", "upload"},
Argv: func() interface{} { return new(putT) },
Fn: putCLI,

NumOption: cli.AtLeast(1),
}
Expand Down

0 comments on commit ddd8500

Please sign in to comment.