j-maly / CommandLineParser

Command line parser. Declarative arguments support. Rich set of argument types (switches, enums, files, etc...). Mutually exclusive arguments validations.
MIT License
137 stars 30 forks source link

Invalid parsing when argument value begins with a slash #26

Closed Skippeh closed 7 years ago

Skippeh commented 7 years ago

If you for example have:

--filePath /root/folder

You will get the error:

Grouping of multiple short name arguments in one word(e.g. -a -b into -ab) is allowed only for switch arguments.Argument r is not a switch argument.

Surrounding the path with quotation marks doesn't help.

j-maly commented 7 years ago

Hi, thanks for reporting this, I'll fix it. As a workaround, setting CommandLineParser.AcceptSlash to false might help here.

j-maly commented 7 years ago

This is a problem of some features being enabled by default not playing well together in this case. So you can disable one of these AllowShortSwitchGrouping (which is for treating -abc as -a -b -c) AcceptSlash (which allows switches written as /a /b /c)

But I've added a check to the parser to be less eager trying to expand switches. So your example --filePath /root/folder should work in the next version, even with the default settings.