diff --git a/command.go b/command.go index 6bbb53a..980b1b2 100644 --- a/command.go +++ b/command.go @@ -600,7 +600,7 @@ func writeArgumentsSection(cmd *Command, s *strings.Builder) error { case requiredArgMarker: tab.Row(" %s\t%s [required]\n", colour.Bold(arg.name), arg.description) case "": - tab.Row(" %s\t%s\n", colour.Bold(arg.name), arg.description) + tab.Row(" %s\t%s [default %q]\n", colour.Bold(arg.name), arg.description, arg.defaultValue) default: tab.Row(" %s\t%s [default %s]\n", colour.Bold(arg.name), arg.description, arg.defaultValue) } diff --git a/command_test.go b/command_test.go index 799095e..975e6c1 100644 --- a/command_test.go +++ b/command_test.go @@ -464,6 +464,7 @@ func TestHelp(t *testing.T) { cli.OverrideArgs([]string{"--help"}), cli.RequiredArg("src", "The file to copy"), // This one is required cli.OptionalArg("dest", "Destination to copy to", "./dest"), // This one is optional + cli.OptionalArg("other", "Something else", ""), // This is optional but default is empty cli.Run(func(cmd *cli.Command, args []string) error { return nil }), }, wantErr: false, diff --git a/testdata/snapshots/TestHelp/with_named_arguments.snap.txt b/testdata/snapshots/TestHelp/with_named_arguments.snap.txt index 2642bea..e50688d 100644 --- a/testdata/snapshots/TestHelp/with_named_arguments.snap.txt +++ b/testdata/snapshots/TestHelp/with_named_arguments.snap.txt @@ -1,10 +1,11 @@ A placeholder for something cool -Usage: test [OPTIONS] SRC [DEST] +Usage: test [OPTIONS] SRC [DEST] [OTHER] Arguments: - src The file to copy [required] - dest Destination to copy to [default ./dest] + src The file to copy [required] + dest Destination to copy to [default ./dest] + other Something else [default ""] Options: -h --help bool Show help for test