diff --git a/args_test.go b/args_test.go index 077a2f3f..ec17fdc7 100644 --- a/args_test.go +++ b/args_test.go @@ -560,6 +560,21 @@ func ExampleWithUsage() { cmd := &Command{ Use: "example ", Args: WithUsage(ExactArgs(1)), + Run: func(*Command, []string) { + panic("not reached") + }, } - _ = cmd // ignore unused + + cmd.SetArgs([]string{"1", "2"}) + err := cmd.Execute() + fmt.Print(err) + + // Output: + // accepts 1 arg(s), received 2 + // + // Usage: + // example [flags] + // + // Flags: + // -h, --help help for example }