Skip to content

Commit

Permalink
Tweak the help layout
Browse files Browse the repository at this point in the history
  • Loading branch information
FollowTheProcess committed Jan 4, 2025
1 parent b025f28 commit b27f2e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions testdata/snapshots/TestHelp/with_named_arguments.snap.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b27f2e1

Please sign in to comment.