-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrectly parsed "--" argument #99
Comments
Oh crumbs yes I can see that happening. -- tells the parser to stop searching for switches after that point and instead treat them as values. It needs fixing so that if the -- is a string value itself such as "--" or '--' then it should be recognised as a string value and not a special token. |
I've just tried app.exe -a "-javascript-delay 3000 -q --no-outline --encoding utf-8 --user-style-sheet defaults/default-css.css" expected result is to get parameter a with -javascript-delay 3000 -q --no-outline --encoding utf-8 --user-style-sheet defaults/default-css.css value Is it the same case ? |
Yes looks exactly the same case unfortunately |
looks strange I've just added tests as below class when_args_contains_double_dash_value : ParseTestContext
{
Establish context = () => SetupArgs("-a \"--\"");
It should_return_a_single_option = () =>
result.ParsedOptions.Count().ShouldEqual(1);
It should_set_the_parsed_option_name = () =>
result.ParsedOptions.First().Key.ShouldEqual("a");
It should_set_the_parsed_option_value_to_the_double_dash = () =>
result.ParsedOptions.First().Value.ShouldEqual("\"--\"");
}
class when_args_contains_double_dash_value_complex : ParseTestContext
{
Establish context = () => SetupArgs("-a \"--ignored-switch-value 1234\"");
It should_return_a_single_option = () =>
result.ParsedOptions.Count().ShouldEqual(1);
It should_set_the_parsed_option_value_to_the_double_dash = () =>
result.ParsedOptions.First().Value.ShouldEqual("\"--ignored-switch-value 1234\"");
}
class when_args_contains_single_dash_value : ParseTestContext
{
Establish context = () => SetupArgs("-a \"-\"");
It should_return_a_single_option = () =>
result.ParsedOptions.Count().ShouldEqual(1);
It should_set_the_parsed_option_name = () =>
result.ParsedOptions.First().Key.ShouldEqual("a");
It should_set_the_parsed_option_value_to_the_double_dash = () =>
result.ParsedOptions.First().Value.ShouldEqual("\"-\"");
}
class when_args_contains_single_dash_value_complex : ParseTestContext
{
Establish context = () => SetupArgs("-a \"-ignored-switch-value 1234\"");
It should_return_a_single_option = () =>
result.ParsedOptions.Count().ShouldEqual(1);
It should_set_the_parsed_option_value_to_the_double_dash = () =>
result.ParsedOptions.First().Value.ShouldEqual("\"-ignored-switch-value 1234\"");
} to the Does it mean that the |
ok, here is my testing result for the case when argument value contains static void Main(string[] args)
{
foreach (var a in args)
Log.DebugFormat("input argument:{0}", a);
} for command line like
output is
so second parameter has got value with space inside but To override this
this produces expected output
as you can see first and when FCLP I've checked this for FCLP 1.4.3, 1.5.0.20 and develop branch - it works as expected if there is escaped double quote in the argument value. Probably it has to be documented but I'm not sure that this is a bug. It is rather a feature ;-) |
@oleksabor ha ha thanks for your extensive investigation, I'm not sure what "feature" to call this !? I've seen it many times before where .NET has already interpreted the commands args badly before they even get to FCLP. In that situation the library can't really do anything to help, so it is important that this is understood. Thanks again |
With folowing command line arguments are not parsed correctly
app.exe --xx "--" --yy 1 --zz 2
Value mapped for --xx arg is "--yy"
All other values are not parsed and got default values
The text was updated successfully, but these errors were encountered: