···181181 command string // The command string for the example.
182182}
183183184184-// String implements [fmt.Stringer] for [Example].
185185-func (e example) String() string {
186186- return fmt.Sprintf("\n # %s\n $ %s\n", e.comment, e.command)
187187-}
188188-189184// Execute parses the flags and arguments, and invokes the Command's Run
190185// function, returning any error.
191186//
+22
command_test.go
···6464 },
6565 wantErr: true,
6666 },
6767+ {
6868+ name: "bad arg",
6969+ stdout: "",
7070+ stderr: "",
7171+ options: []cli.Option{
7272+ cli.OverrideArgs([]string{"arg1", "notanumber"}), // Provided arg for 'second' is not an int
7373+ cli.Arg(new(string), "first", "The first arg"),
7474+ cli.Arg(new(int), "second", "The second arg"),
7575+ },
7676+ wantErr: true,
7777+ },
7878+ {
7979+ name: "missing required argument",
8080+ stdout: "",
8181+ stderr: "",
8282+ options: []cli.Option{
8383+ cli.OverrideArgs([]string{"hello"}), // "second" is not provided
8484+ cli.Arg(new(string), "first", "The first word"), // Expect the positional arguments
8585+ cli.Arg(new(string), "second", "The second word"),
8686+ },
8787+ wantErr: true,
8888+ },
6789 }
68906991 for _, tt := range tests {