Skip to content

Commit

Permalink
Add version example
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Oct 29, 2021
1 parent 910d5d7 commit 667f9a7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,24 @@ func ExampleHelp() {
//
// Version: the best v0.x.y
}

func ExampleVersion() {
cmds := []acmd.Command{
{Name: "foo", Do: nopFunc},
{Name: "bar", Do: nopFunc},
}

r := acmd.RunnerOf(cmds, acmd.Config{
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
Output: os.Stdout,
Args: []string{"version"},
})

if err := r.Run(); err != nil {
panic(err)
}

// Output: acmd-example version: the best v0.x.y
}

0 comments on commit 667f9a7

Please sign in to comment.