Skip to content

Commit

Permalink
ffcli: add DESCRIPTION with Shorthelp to DefaultUsageFunc (#111)
Browse files Browse the repository at this point in the history
* ffcli: DefaultUsageFunc: add DESCRIPTION with ShortHelp

* ffcli: fix tests
  • Loading branch information
peterbourgon authored Jun 16, 2023
1 parent a98a914 commit 858a455
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ffcli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ func (e NoExecError) Error() string {
func DefaultUsageFunc(c *Command) string {
var b strings.Builder

if c.ShortHelp != "" {
fmt.Fprintf(&b, "DESCRIPTION\n")
fmt.Fprintf(&b, " %s\n", c.ShortHelp)
fmt.Fprintf(&b, "\n")
}

fmt.Fprintf(&b, "USAGE\n")
if c.ShortUsage != "" {
fmt.Fprintf(&b, " %s\n", c.ShortUsage)
Expand Down
3 changes: 3 additions & 0 deletions ffcli/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ func assertStringSlice(t *testing.T, want, have []string) {
}

var defaultUsageFuncOutput = strings.TrimSpace(`
DESCRIPTION
Some short help.
USAGE
TestHelpUsage [flags] <args>
Expand Down

0 comments on commit 858a455

Please sign in to comment.