Skip to content

Commit

Permalink
Be passive-aggressive about description
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Oct 28, 2021
1 parent a6e4347 commit 656e0f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 6 additions & 2 deletions acmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var defaultUsage = func(w io.Writer) func(cfg Config, cmds []Command) {
fmt.Fprintf(w, "%s\n\n", cfg.AppDescription)
}

fmt.Fprintf(w, "Usage:\n\n %s <command> [arguments]\n\nThe commands are:\n\n", cfg.AppName)
fmt.Fprintf(w, "Usage:\n\n %s <command> [arguments...]\n\nThe commands are:\n\n", cfg.AppName)
printCommands(w, cmds)

if cfg.Version != "" {
Expand All @@ -182,7 +182,11 @@ func printCommands(w io.Writer, cmds []Command) {
minwidth, tabwidth, padding, padchar, flags := 0, 0, 11, byte(' '), uint(0)
tw := tabwriter.NewWriter(w, minwidth, tabwidth, padding, padchar, flags)
for _, cmd := range cmds {
fmt.Fprintf(tw, " %s\t%s\n", cmd.Name, cmd.Description)
desc := cmd.Description
if desc == "" {
desc = "<no description>"
}
fmt.Fprintf(tw, " %s\t%s\n", cmd.Name, desc)
}
fmt.Fprint(tw, "\n")
tw.Flush()
Expand Down
9 changes: 4 additions & 5 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ func ExampleHelp() {
Do: nopFunc,
},
{
Name: "boom",
Description: "bombom",
Do: nopFunc,
Name: "boom",
Do: nopFunc,
},
}

Expand All @@ -92,11 +91,11 @@ func ExampleHelp() {
//
// Usage:
//
// acmd-example <command> [arguments]
// acmd-example <command> [arguments...]
//
// The commands are:
//
// boom bombom
// boom <no description>
// help shows help message
// now prints current time
// status prints status of the system
Expand Down

0 comments on commit 656e0f2

Please sign in to comment.