Reproducer
fs := flag.NewFlagSet("example", flag.ContinueOnError)
enabled := fs.Bool("enabled", false, "")
err := xflag.ParseToEnd(fs, []string{"--", "--enabled"})
fmt.Println(err, *enabled, fs.Args())
Current output:
Expected output:
-- is the end-of-options delimiter, so everything following it should remain positional even when it looks like a flag.
flag.FlagSet.Parse strips the delimiter, after which ParseToEnd scans the remaining arguments and parses --enabled a second time. Splitting the original arguments at -- before parsing would preserve the delimiter semantics.
This affects direct users of xflag.ParseToEnd; cli.Parse already splits its arguments at -- first.
Reproducer
Current output:
Expected output:
--is the end-of-options delimiter, so everything following it should remain positional even when it looks like a flag.flag.FlagSet.Parsestrips the delimiter, after whichParseToEndscans the remaining arguments and parses--enableda second time. Splitting the original arguments at--before parsing would preserve the delimiter semantics.This affects direct users of
xflag.ParseToEnd;cli.Parsealready splits its arguments at--first.