Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repeated [arguments...] in usage template in v2 #1872

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func ExampleApp_Run_commandHelp() {
Aliases: []string{"d"},
Usage: "use it to see a description",
Description: "This is how we describe describeit the function",
Args: true,
Action: func(c *Context) error {
fmt.Printf("i like to describe things")
return nil
Expand Down Expand Up @@ -227,7 +228,7 @@ func ExampleApp_Run_subcommandNoAction() {
// greet describeit - use it to see a description
//
// USAGE:
// greet describeit [command options] [arguments...]
// greet describeit [command options]
//
// DESCRIPTION:
// This is how we describe describeit the function
Expand Down Expand Up @@ -1912,6 +1913,7 @@ func TestApp_Run_SubcommandFullPath(t *testing.T) {
subCmd := &Command{
Name: "bar",
Usage: "does bar things",
Args: true,
}
cmd := &Command{
Name: "foo",
Expand Down Expand Up @@ -1946,6 +1948,7 @@ func TestApp_Run_SubcommandHelpName(t *testing.T) {
Name: "bar",
HelpName: "custom",
Usage: "does bar things",
Args: true,
}
cmd := &Command{
Name: "foo",
Expand Down Expand Up @@ -1980,6 +1983,7 @@ func TestApp_Run_CommandHelpName(t *testing.T) {
subCmd := &Command{
Name: "bar",
Usage: "does bar things",
Args: true,
}
cmd := &Command{
Name: "foo",
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cli

var helpNameTemplate = `{{$v := offset .HelpName 6}}{{wrap .HelpName 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}}`
var usageTemplate = `{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}{{if .Args}}[arguments...]{{end}}[arguments...]{{end}}{{end}}`
var usageTemplate = `{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}}{{if .ArgsUsage}}{{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}`
var descriptionTemplate = `{{wrap .Description 3}}`
var authorsTemplate = `{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
{{range $index, $author := .Authors}}{{if $index}}
Expand Down
Loading