-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow repeating an option to override its value #22
Conversation
stefantalpalaru
commented
Aug 31, 2020
./tests/cli_example --foo:1 --bar:a --withBaz --foo:2 --bar:boo --bar:hoo --withBaz:false foo = 2 bar = hoo baz = false
Because this PR do not have any tests, it could break handling sequence arguments, for example when one of the arguments are declared like this https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/conf.nim#L92-L95 you can supply multiple items only via:
And this behavior should be preserved, or new one should be introduced. |
As I already explained in Discord, there is no such breakage: diff --git a/tests/cli_example.nim b/tests/cli_example.nim
index 2271320..e5773e1 100644
--- a/tests/cli_example.nim
+++ b/tests/cli_example.nim
@@ -1,9 +1,10 @@
import
../confutils
-cli do (foo: int, bar: string, withBaz: bool, args {.argument.}: seq[string]):
+cli do (foo: int, bar: string, withBaz: bool, bootstrapNodes: seq[string], args {.argument.}: seq[string]):
echo "foo = ", foo
echo "bar = ", bar
echo "baz = ", withBaz
+ echo "bootstrapNodes = ", bootstrapNodes
for arg in args: echo "arg ", arg
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but IIRC @zah had reserves on the behavior until you cited an actual spec on CLI parsing, can you link to the spec so that we can put that in the documentation at an opportune time.
"If an option that has option-arguments is repeated, the option and option-argument combinations should be interpreted in the order specified on the command line." - https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
|