Skip to content

Commit

Permalink
Merge pull request #1872 from edeustua/v2-maint
Browse files Browse the repository at this point in the history
Fix repeated [arguments...] in usage template in v2
  • Loading branch information
dearchap authored Mar 7, 2024
2 parents 8728c19 + fa2b127 commit 67566bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit 67566bb

Please sign in to comment.