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
Switch(flag: "f", key: "force", usage: "Whether to force")
Surprisingly, calling my-tool do something -f has a different than my-tool do something --force. The former one works, while the latter fails.
However, if the switch is initialized with: Switch(flag: nil, key: "force", usage: "Whether to force"), without a flag, --force works.
This is due to a (what I understand as a) bug in the Switch <| function:
case let.arguments(arguments):var enabled = arguments.consume(key: option.key)
if let flag = option.flag {
enabled = arguments.consumeBoolean(flag: flag)}
return .success(enabled)
You can see that, when a flag exists, it will always read try to read if the flag was passed, and this will override the value if the key was passed.
Imagine the following scenario:
Switch(flag: "f", key: "force", usage: "Whether to force")
Surprisingly, calling
my-tool do something -f
has a different thanmy-tool do something --force
. The former one works, while the latter fails.However, if the switch is initialized with:
Switch(flag: nil, key: "force", usage: "Whether to force")
, without a flag,--force
works.This is due to a (what I understand as a) bug in the Switch
<|
function:You can see that, when a flag exists, it will always read try to read if the flag was passed, and this will override the value if the key was passed.
I've opened a PR with tests and the fix for them.
The text was updated successfully, but these errors were encountered: