args icon indicating copy to clipboard operation
args copied to clipboard

issue on option with a dot in its name

Open a14n opened this issue 5 years ago • 4 comments

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

a14n avatar Aug 30 '18 12:08 a14n

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?

natebosch avatar Dec 11 '20 03:12 natebosch

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.

munificent avatar Dec 16 '20 01:12 munificent

Can you include dot to the pattern? The dot is commonly used like this: curl --http1.1 https://example.com

MegatronKing avatar Apr 09 '22 06:04 MegatronKing

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.

munificent avatar Apr 21 '22 21:04 munificent