fclp / fluent-command-line-parser

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface
Other
530 stars 86 forks source link

Bug: longName doesn't work if shortName not supplied #24

Closed BryanCrotaz closed 9 years ago

BryanCrotaz commented 10 years ago

Fails to find option -engine="c:\engine.txt":

cmdLine.Setup<string>("engine").Required().Callback(value => Engine = value);

Finds option -engine="c:\engine.txt":

cmdLine.Setup<string>('e', "engine").Required().Callback(value => Engine = value);

siywilliams commented 10 years ago

Not really a bug, - is to denote a short option and -- is for long options.

FCLP supports combined short options, so if you input -pT it will be parsed as two seperate short options, -p and -T.

So with -engine, FCLP thinks you are combining short options and interprets it as -e -n -g -i -n -e. Because in the first setup you've only specified a long option it does not find a match. However in your second setup you specify the short option e which it matches.

Make sense?

If you specified --engine="c:\engine.txt" it would parse as expected because you're correctly denoting a long option.

BryanCrotaz commented 10 years ago

Please add this to examples of use - the examples don't show how to use a long option

On 1 September 2014 14:32, Siy Williams notifications@github.com wrote:

Not really a bug, - is to denote a short option and -- is for long options.

FCLP supports combined short options, so if you input -pT it will be parsed as two seperate short options, -p and -T.

So with -engine, FCLP thinks you are combining short options and interprets it as -e -n -g -i -n -e. Because in the first setup you've only specified a long option it does not find a match. However in your second setup you specify the short option e which it matches.

Make sense?

If you specified --engine="c:\engine.txt" it would parse as expected because you're correctly denoting a long option.

— Reply to this email directly or view it on GitHub https://github.com/fclp/fluent-command-line-parser/issues/24#issuecomment-54059199 .

Bryan Crotaz Managing Director Silver Curve

siywilliams commented 10 years ago

That's what I intended with the --silient long option in the example, but I can see why it might not be clear because it doesn't show assigning a long option a value.

I will update the example to make it clearer.