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

Conflict between short option and long option - always picks short option #58

Open samjudson opened 8 years ago

samjudson commented 8 years ago

Hi

I've got two options setup, one of which has a short code, which matches the first letter of the other long option.

bool option1Matched = false;
bool option2Matched = false;

p.Setup<string>('t', "option1").Callback(t => option1Matched = true);
p.Setup<string>("test2").Callback(t => option2Matched = true);

p.Parse(new[] {"-test2","value"});

Assert.IsFalse(option1Matched, "option1Matched should be false");
Assert.IsTrue(option2Matched, "option2Matched should be true");

The option passed in is "test2" but the "t" setup option is being called. Surely in this instance the most exact match (the second "test2" option) should be matched?

samjudson commented 8 years ago

OK, I've found the 'issue': The "-" prefix prefers short options, over long options, and I should be using "--" to enforce the long option.

Still not sure if this is the 'correct' behaviour when the option is an exact match on a long option - its certainly not intuitive to me. Any thoughts?

TheR00st3r commented 8 years ago

Same issue here

siywilliams commented 6 years ago

Unfortunately as designed, see https://github.com/fclp/fluent-command-line-parser/issues/24 as this lib follows unix conventions.

We do really need to put in an option to disable short options though which would be a much nicer solution for people that like using -silent style.

siywilliams commented 6 years ago

In v1.5 you will be able to do var fclp = new FluentCommandLineParser().DisableShortOptions();