Closed sj14 closed 5 years ago
cmdBspecific := cmdA.String("bspec", "only visible for cmd B", "only visible for cmd B")
Looks like you added bpsec to cmdA...
@eparis oh, you are right. But after changing it, it's still the same issue.
ok, i'll play with it. But it looks like you are duplicating basically exactly what github.com/spf13/cobra provides....
defaults.Parse(os.Args)
is your problem. You are parsing os.Args on a flag set that doesn't container bspec. If you just delete that entirely it works, since you parse the default flag set and the a/b specific flags later inside the switch. (though maybe you want to put this inside the default
portion of the switch.
Ah, thanks alot!
Hi, I try to use
pflag
for sub commands with multiple flag sets. Please see the example below.cmda
/cmdb
without flags works as expected.But not with flags. I thought this should be possbile, where is my mistake?