allow overriding help name
This commit is contained in:
parent
aced6e8739
commit
cc46ca1020
8
app.go
8
app.go
@ -89,7 +89,9 @@ func (a *App) Run(arguments []string) (err error) {
|
|||||||
|
|
||||||
newCmds := []Command{}
|
newCmds := []Command{}
|
||||||
for _, c := range a.Commands {
|
for _, c := range a.Commands {
|
||||||
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
|
if c.HelpName == "" {
|
||||||
|
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
|
||||||
|
}
|
||||||
newCmds = append(newCmds, c)
|
newCmds = append(newCmds, c)
|
||||||
}
|
}
|
||||||
a.Commands = newCmds
|
a.Commands = newCmds
|
||||||
@ -199,7 +201,9 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
|||||||
|
|
||||||
newCmds := []Command{}
|
newCmds := []Command{}
|
||||||
for _, c := range a.Commands {
|
for _, c := range a.Commands {
|
||||||
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
|
if c.HelpName == "" {
|
||||||
|
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
|
||||||
|
}
|
||||||
newCmds = append(newCmds, c)
|
newCmds = append(newCmds, c)
|
||||||
}
|
}
|
||||||
a.Commands = newCmds
|
a.Commands = newCmds
|
||||||
|
@ -157,7 +157,12 @@ func (c Command) startApp(ctx *Context) error {
|
|||||||
|
|
||||||
// set the name and usage
|
// set the name and usage
|
||||||
app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
|
app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
|
||||||
app.HelpName = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
|
if c.HelpName == "" {
|
||||||
|
app.HelpName = c.HelpName
|
||||||
|
} else {
|
||||||
|
app.HelpName = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
|
||||||
|
}
|
||||||
|
|
||||||
if c.Description != "" {
|
if c.Description != "" {
|
||||||
app.Usage = c.Description
|
app.Usage = c.Description
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user