You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modifying the sliceFlag example to include a subcommand like:
package main
import "github.com/integrii/flaggy"
func main() {
// Declare variables and their defaults
var stringSliceFlag []string
var boolSliceFlag []bool
// Add a slice flag
flaggy.DefaultParser.AdditionalHelpAppend = "Example: ./sliceFlag -b -b -s one -s two -b=false"
flaggy.StringSlice(&stringSliceFlag, "s", "string", "A test string slice flag")
flaggy.BoolSlice(&boolSliceFlag, "b", "bool", "A test bool slice flag")
testSubcommand := flaggy.NewSubcommand("test")
testSubcommand.Description = "Testing"
testSubcommand.ShortName = "test"
flaggy.AttachSubcommand(testSubcommand, 1)
// Parse the flag
flaggy.Parse()
// output the flag contents
for i := range stringSliceFlag {
println(stringSliceFlag[i])
}
for i := range boolSliceFlag {
println(boolSliceFlag[i])
}
}
Results in:
$ ./main -b -b -s one -s two -b=false
one
two
true
true
false
$ ./main -b -b -s one -s two -b=false test
one
two
one
two
true
true
false
true
true
false
Otherwise, perhaps a more thorough approach is to consider the depth of the flag being parsed. If the flag doesn't belong to the current depth then ignore it.
The text was updated successfully, but these errors were encountered:
Modifying the sliceFlag example to include a subcommand like:
Results in:
It appears all args are passed to the recursed subcommand here: https://github.com/integrii/flaggy/blob/master/subCommand.go#L280. Perhaps only the arguments to the right of the subcommand in the args should be passed?
Otherwise, perhaps a more thorough approach is to consider the depth of the flag being parsed. If the flag doesn't belong to the current depth then ignore it.
The text was updated successfully, but these errors were encountered: