Closed fcharlie closed 2 months ago
I use kong to parse command line, but I found some problems while using it, one of them is "duplicate flag".
package main import "github.com/alecthomas/kong" var CLI struct { Rm struct { Force bool `help:"Force removal."` Recursive bool `help:"Recursively remove files."` Paths []string `arg:"" name:"path" help:"Paths to remove." type:"path"` Fast bool `name:"fast" negatable:"" help:"fast check"` } `cmd:"" help:"Remove files."` Ls struct { Paths []string `arg:"" optional:"" name:"path" help:"Paths to list." type:"path"` Fast bool `name:"fast" negatable:"" help:"fast check"` } `cmd:"" help:"List paths."` } func main() { ctx := kong.Parse(&CLI) switch ctx.Command() { case "rm <path>": case "ls": default: panic(ctx.Command()) } }
package main import "github.com/alecthomas/kong" var CLI struct { Config []string `help:"config value" short:"c"` Rm struct { Force bool `help:"Force removal."` Recursive bool `help:"Recursively remove files."` Paths []string `arg:"" name:"path" help:"Paths to remove." type:"path"` } `cmd:"" help:"Remove files."` Branch struct { Paths []string `arg:"" optional:"" name:"path" help:"Paths to list." type:"path"` Create bool `name:"create" short:"c" help:"Create branch"` } `cmd:"" help:"List paths."` } func main() { ctx := kong.Parse(&CLI) switch ctx.Command() { case "rm <path>": case "ls": default: panic(ctx.Command()) } }
In addition, it would be great if commands like git -c X=value switch -c new-branch could be supported. (First -c set config to command)
git -c X=value switch -c new-branch
-c
Thanks for the bug report!
I use kong to parse command line, but I found some problems while using it, one of them is "duplicate flag".
In addition, it would be great if commands like
git -c X=value switch -c new-branch
could be supported. (First-c
set config to command)