cli
cli copied to clipboard
Could support the SkipFlagParsing is true with flags?
Could support the SkipFlagParsing is true with flags?
For example:
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
var uuid cli.StringSlice
app.Commands = []cli.Command{
{
Name: "test",
Usage: "cli testing",
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "uuid", Value: &uuid},
},
Action: func(c *cli.Context) {
fmt.Fprintf(os.Stdout, "uuid: %v\n", uuid)
for _, x := range c.Args() {
fmt.Fprintln(os.Stdout, x)
}
},
SkipFlagParsing: false,
},
}
app.Run(os.Args)
}
It outputs:
go run test2.go test -uuid foobar -a a
Incorrect Usage: flag provided but not defined: -a
NAME:
test2 test - cli testing
USAGE:
test2 test [command options] [arguments...]
OPTIONS:
--uuid value (default: "foobar")
Expect:
uuid: [foobar]
-a
a
+1 need that
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.
+1
This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant.
In general we cant have it both ways, if SkipFlagParsing is false the behaviour is as expected. If SkipFlagParsing is set to true then output is
uuid: []
--uuid
dd
--a
a