BoolFlag.Count
increment once per alias
#1737
Labels
area/v2
relates to / is being considered for v2
kind/bug
describes or fixes a bug
status/triage
maintainers still need to look into this
My urfave/cli version is
v2.25.3
Checklist
Dependency Management
Describe the bug
The value of
.Count
for aBoolFlag
is impacted by the number of aliases defined for that flag.To reproduce
Reproducible program:
Observed behavior
Expected behavior
I would expect the count to be incremented only once, i.e.:
Additional context
Beyond the initial value, things are incremented as expected:
Want to fix this yourself?
I'd be happy to, though I don't think I have enough context to implement a suitable solution. The trace is:
.Apply
aBoolFlag
we copy thecount
pointer for each aliascli/flag_bool.go
Line 138 in dc77f3c
.Set
the flag we increment this countcli/flag_bool.go
Line 38 in dc77f3c
So when we run a command:
cli/command.go
Line 158 in acbbbf2
cli/command.go
Line 384 in acbbbf2
cli/flag.go
Line 229 in acbbbf2
cli/flag.go
Line 199 in acbbbf2
Consequently the flag is
.Set
once per alias, so the count is incremented once per alias.Maybe flag types could implement the copying logic themselves?
Run
go version
and paste its output hereRun
go env
and paste its output hereThe text was updated successfully, but these errors were encountered: