Skip to content

Commit

Permalink
Add PostDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Jan 9, 2022
1 parent 4b675a6 commit e11dd90
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
6 changes: 6 additions & 0 deletions acmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type Config struct {
// AppDescription is an optional description. default is empty.
AppDescription string

// PostDescription of the command. Is shown after a help.
PostDescription string

// Version of the application.
Version string

Expand Down Expand Up @@ -301,6 +304,9 @@ func defaultUsage(w io.Writer) func(cfg Config, cmds []Command) {
fmt.Fprintf(w, "Usage:\n\n %s <command> [arguments...]\n\nThe commands are:\n\n", cfg.AppName)
printCommands(w, cmds)

if cfg.PostDescription != "" {
fmt.Fprintf(w, "%s\n\n", cfg.PostDescription)
}
if cfg.Version != "" {
fmt.Fprintf(w, "Version: %s\n\n", cfg.Version)
}
Expand Down
26 changes: 15 additions & 11 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ func ExampleRunner() {
}

r := acmd.RunnerOf(cmds, acmd.Config{
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
Output: testOut,
Args: testArgs,
Usage: nopUsage,
AppName: "acmd-example",
AppDescription: "Example of acmd package",
PostDescription: "Best place to add examples",
Version: "the best v0.x.y",
Output: testOut,
Args: testArgs,
Usage: nopUsage,
})

if err := r.Run(); err != nil {
Expand Down Expand Up @@ -97,11 +98,12 @@ func ExampleHelp() {
}

r := acmd.RunnerOf(cmds, acmd.Config{
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
Output: testOut,
Args: testArgs,
AppName: "acmd-example",
AppDescription: "Example of acmd package",
PostDescription: "Best place to add examples.",
Version: "the best v0.x.y",
Output: testOut,
Args: testArgs,
})

if err := r.Run(); err != nil {
Expand All @@ -122,6 +124,8 @@ func ExampleHelp() {
// status prints status of the system
// version shows version of the application
//
// Best place to add examples.
//
// Version: the best v0.x.y
}

Expand Down

0 comments on commit e11dd90

Please sign in to comment.