Skip to content

Commit 4012229

Browse files
committed
Merge branch 'main' of github.com:urfave/cli into main
2 parents 51ee949 + 41334d4 commit 4012229

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ jobs:
2727
go-version: stable
2828

2929
- name: Run golangci-lint
30-
uses: golangci/golangci-lint-action@v8
30+
uses: golangci/golangci-lint-action@v9
3131
with:
3232
version: latest

godoc-current.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ var AnyArguments = []Argument{
5757
}
5858
AnyArguments to differentiate between no arguments(nil) vs aleast one
5959

60+
var ArgsUsageCommandHelp = "[command]"
61+
ArgsUsageCommandHelp is a short description of the arguments of the help
62+
command
63+
6064
var CommandHelpTemplate = `NAME:
6165
{{template "helpNameTemplate" .}}
6266

@@ -172,6 +176,10 @@ OPTIONS:{{template "visibleFlagTemplate" .}}{{end}}
172176
cli.go uses text/template to render templates. You can render custom help
173177
text by setting this variable.
174178

179+
var UsageCommandHelp = "Shows a list of commands or help for one command"
180+
UsageCommandHelp is the text to override the USAGE section of the help
181+
command
182+
175183
var VersionPrinter = DefaultPrintVersion
176184
VersionPrinter prints the version for the root Command.
177185

help.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,18 @@ var ShowCommandHelp = DefaultShowCommandHelp
5656
// ShowSubcommandHelp prints help for the given subcommand
5757
var ShowSubcommandHelp = DefaultShowSubcommandHelp
5858

59+
// UsageCommandHelp is the text to override the USAGE section of the help command
60+
var UsageCommandHelp = "Shows a list of commands or help for one command"
61+
62+
// ArgsUsageCommandHelp is a short description of the arguments of the help command
63+
var ArgsUsageCommandHelp = "[command]"
64+
5965
func buildHelpCommand(withAction bool) *Command {
6066
cmd := &Command{
6167
Name: helpName,
6268
Aliases: []string{helpAlias},
63-
Usage: "Shows a list of commands or help for one command",
64-
ArgsUsage: "[command]",
69+
Usage: UsageCommandHelp,
70+
ArgsUsage: ArgsUsageCommandHelp,
6571
HideHelp: true,
6672
}
6773

help_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,3 +2009,26 @@ func TestPrintHelpCustomTemplateError(t *testing.T) {
20092009
*tmpl = oldtmpl
20102010
}
20112011
}
2012+
2013+
func TestCustomUsageCommandHelp(t *testing.T) {
2014+
old := UsageCommandHelp
2015+
defer func() { UsageCommandHelp = old }()
2016+
2017+
UsageCommandHelp = "Custom usage help command"
2018+
2019+
out := &bytes.Buffer{}
2020+
cmd := &Command{
2021+
Name: "app",
2022+
Commands: []*Command{
2023+
{
2024+
Name: "cmd",
2025+
Commands: []*Command{{Name: "subcmd"}},
2026+
},
2027+
},
2028+
Writer: out,
2029+
ErrWriter: out,
2030+
}
2031+
2032+
_ = cmd.Run(buildTestContext(t), []string{"app", "help"})
2033+
assert.Contains(t, out.String(), UsageCommandHelp)
2034+
}

testdata/godoc-v3.x.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ var AnyArguments = []Argument{
5757
}
5858
AnyArguments to differentiate between no arguments(nil) vs aleast one
5959

60+
var ArgsUsageCommandHelp = "[command]"
61+
ArgsUsageCommandHelp is a short description of the arguments of the help
62+
command
63+
6064
var CommandHelpTemplate = `NAME:
6165
{{template "helpNameTemplate" .}}
6266

@@ -172,6 +176,10 @@ OPTIONS:{{template "visibleFlagTemplate" .}}{{end}}
172176
cli.go uses text/template to render templates. You can render custom help
173177
text by setting this variable.
174178

179+
var UsageCommandHelp = "Shows a list of commands or help for one command"
180+
UsageCommandHelp is the text to override the USAGE section of the help
181+
command
182+
175183
var VersionPrinter = DefaultPrintVersion
176184
VersionPrinter prints the version for the root Command.
177185

0 commit comments

Comments
 (0)