Open Skeeve opened 3 days ago
@Skeeve This looks very much like #1737 which was fixed in v2 but not ported to v3. Think you can make a PR ?
Think you can make a PR ?
I doubt it :(
I THINK the issue might be due to these two lines:
https://github.com/urfave/cli/blob/c4cd0a51cc113a90eca318cc8f7d328f05a5f2b7/flag_impl.go#L169
and
https://github.com/urfave/cli/blob/c4cd0a51cc113a90eca318cc8f7d328f05a5f2b7/flag_bool.go#L66
But I'm not so deep in understanding the source that I can tell for sure.
I'm also wondering: It seems, ALL flags are counted. Why is Count()
only available for BoolfFlag
? Sure, it's the only Flag wit Countable
set, but what's the purpose hiding this info from the user, when it's already available?
No one has requested count for non-bool flags. Not sure when I can get around to a fix though.
No one has requested count for non-bool flags. Not sure when I can get around to a fix though.
That "fix" (if it is a fix) should be easy. Just get rid of "if Countable" in the Count function.
@Skeeve Would you like to submit a PR with the change ? I'll get glad to review it.
I would like to, but I can't. I have the slight feeling there is more wrong to it, than I first thought.
Here are my observations.
count
memberBoolConfig
which has a member Count
Count
is never incremented nor returned. At least I was unable to find it and I assume this should have been done.I created a test command for counting bools.
I also thought about counting all flags. I think it only makes sense for the …SliceFlag
s as all the others usually are not used more than once.
Checklist
What problem did you observe?
When using cmd.Count("verbose") on my bool flag, it's value is always one too high
Test Program
Also on playground: https://play.golang.com/p/om6L1TD_6s5