From 667f9a78b6bdc1780579b7129890e854782cbd58 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 29 Oct 2021 16:40:38 +0200 Subject: [PATCH] Add version example --- example_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/example_test.go b/example_test.go index 4b2bbb1..4fe57b6 100644 --- a/example_test.go +++ b/example_test.go @@ -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 +}