Skip to content

Commit 4615521

Browse files
authored
Merge pull request #58 from choria-io/57
(#57) Show command aliases in help
2 parents 3960734 + ad0a5bd commit 4615521

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Diff for: cmd.go

+4
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ type CmdClause struct {
237237
pluginDelegator *pluginDelegator
238238
}
239239

240+
func (c *CmdClause) Aliases() []string {
241+
return c.aliases
242+
}
243+
240244
func newCommand(app *Application, name, help string) *CmdClause {
241245
c := &CmdClause{
242246
app: app,

Diff for: templates.go

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ Commands:
127127
Flags:
128128
{{.Context.SelectedCommand.Flags|FlagsToTwoColumns|FormatTwoColumns}}
129129
{{end -}}
130+
{{ if len .Context.SelectedCommand.Aliases -}}
131+
Command Aliases: {{ .Context.SelectedCommand.Aliases | Join }}
132+
{{end }}
130133
{{end -}}
131134
{{if GlobalFlags .Context|VisibleFlags -}}
132135
{{if .HelpFlagIsSet -}}

Diff for: usage.go

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func (a *Application) UsageForContext(context *ParseContext) error {
136136
func (a *Application) UsageForContextWithTemplate(context *ParseContext, indent int, tmpl string) error {
137137
width := guessWidth(a.usageWriter)
138138
funcs := template.FuncMap{
139+
"Join": func(items []string) string { return strings.Join(items, ", ") },
139140
"Indent": func(level int) string {
140141
return strings.Repeat(" ", level*indent)
141142
},

0 commit comments

Comments
 (0)