ConsoleAppFramework
ConsoleAppFramework copied to clipboard
Proposal: always handle values with dashes as parameter names
Proposal
Change behaviour of ConsoleAppEngine.TryGetInvokeArguments method to always handle values starting with dashes as parameter names but not values.
In this case it would be required to pass value starting with dashes wrapped into quotes. For example:
MyApp.Exe command --some-arg "--arg-value-with-leading-dashes"
Motivation
Current parsing mechanism doesn’t provide correct error messages in case if one of multiple parameters is passed without value. For example:
App definition:
public class CommandTests_Single_Two_Required : ConsoleAppBase
{
[RootCommand]
public void Hello(string firstName, string lastName) => Console.WriteLine($"Hello {firstName} {lastName}");
}
Input:
MyApp.Exe --first-name --last-name "TestLastName"
Output:
Required parameter "last-name" not found in argument. args: --first-name --last-name TestLastName
So, "--last-name" is parsed as value of --first-name parameter
Expecting output:
Value for parameter "first-name" is not provided.
@neuecc what do you think? I'm ready to implement this, but it's definitely a breaking change for some cases.
Maybe default behaviour should be leaved untouched with ability to enable strict parsing via ConsoleAppOptions
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.