Skip to content

Commit

Permalink
Cleanup examples
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Oct 29, 2021
1 parent 667f9a7 commit 8a16e79
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
var nopFunc = func(context.Context, []string) error { return nil }

func ExampleRunner() {
testOut := os.Stdout
testArgs := []string{"now"}

const format = "15:04:05"
now, _ := time.Parse("15:04:05", "10:20:30")

Expand Down Expand Up @@ -45,9 +48,8 @@ func ExampleRunner() {
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
Context: nil,
Args: []string{"now"},
Usage: nil,
Output: testOut,
Args: testArgs,
})

if err := r.Run(); err != nil {
Expand All @@ -58,6 +60,9 @@ func ExampleRunner() {
}

func ExampleHelp() {
testOut := os.Stdout
testArgs := []string{"help"}

cmds := []acmd.Command{
{
Name: "now",
Expand All @@ -79,8 +84,8 @@ func ExampleHelp() {
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
Output: os.Stdout,
Args: []string{"help"},
Output: testOut,
Args: testArgs,
})

if err := r.Run(); err != nil {
Expand All @@ -105,6 +110,9 @@ func ExampleHelp() {
}

func ExampleVersion() {
testOut := os.Stdout
testArgs := []string{"version"}

cmds := []acmd.Command{
{Name: "foo", Do: nopFunc},
{Name: "bar", Do: nopFunc},
Expand All @@ -114,8 +122,8 @@ func ExampleVersion() {
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
Output: os.Stdout,
Args: []string{"version"},
Output: testOut,
Args: testArgs,
})

if err := r.Run(); err != nil {
Expand Down

0 comments on commit 8a16e79

Please sign in to comment.