Commit b7c8b77
committed
fix(args): honor explicit value on boolean flags (--flag=false)
parseFlags set a boolean flag to `true` as soon as it matched the flag,
before inspecting an inline `=value`. So `--flag=false` (or `--flag=0`)
was silently set to `true` -- the opposite of what the user typed -- and
the value was discarded.
Honor an explicit value: `--flag=false`/`0`/`no`/`off` -> false; a bare
`--flag` and `--flag=true` (or any other value) stay true, so there is no
behavior change for existing usage.
Adds parseFlags tests for the bare-flag and explicit-value cases.1 parent 5f13ef5 commit b7c8b77
2 files changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
28 | 40 | | |
0 commit comments