args
args copied to clipboard
issue on option with a dot in its name
Not sure if it is wanted but if I use an option with a dot like p.name
then args are not read correctly.
final parser = ArgParser();
parser.addOption('p.name');
print(parser.parse(['--p.name', 'a'])['p.name']); // outputs null
Versions:
-
args-1.5.0
-
dartSDK 2.0.0
It looks like we intentionally only allow options that match a pattern which doesn't include .
, but that isn't documented anywhere.
https://github.com/dart-lang/args/blob/5acb553c0ed2b68c5208c79d123ef1d49be7fdeb/lib/src/parser.dart#L230
At a minimum we should document this on the addOption
method. Potentially we should extend the pattern to include .
.
cc @munificent WDYT?
We should definitely document it, and if the name is invalid, addOption()
should throw eagerly and let you know.
I personally don't find it very compelling to support .
in option names. I think it just confusingly makes it look more like a file extension, but maybe that's just me.
Can you include dot to the pattern? The dot is commonly used like this:
curl --http1.1 https://example.com
Can you include dot to the pattern? The dot is commonly used like this:
curl --http1.1 https://example.com
Yeah, we could definitely extend the regex to allow dots. I do find your example here fairly compelling.