Skip to content
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

parameter value starts with dash (-) howto ? #110

Open
oleksabor opened this issue Apr 28, 2020 · 0 comments
Open

parameter value starts with dash (-) howto ? #110

oleksabor opened this issue Apr 28, 2020 · 0 comments

Comments

@oleksabor
Copy link

oleksabor commented Apr 28, 2020

I'm using the FCLP to get clientid and secret from the command line parameters

It worked fine however I've got secret value generated starting with dash, like -.q=blablablaG0

The problem is that it is not recognised by the FCLP as a parameter value:

public class Config
{
	public string Param { get; set; }
}

[TestFixture]
public class when_parameter_value_start_with_dash
{
	[Test]
	public void parser() 
	{
		var args = new[] { "-p", "-.q=blablablaG0" };

		var sut = new Fclp.FluentCommandLineParser<Config>();
		sut.Setup(_ => _.Param).As('p', "param");
		var res = sut.Parse(args);

		Assert.AreEqual("-.q=blablablaG0", sut.Object.Param);
	}

}

the test fails with

Message: Expected: "-.q=blablablaG0"
But was: null

How can I pass parameter value starting with dash ?

I've tried to pass parameter value quoted with double quotes as var args = new[] { "--param", "\"-.q=blablablaG0\"" };

It worked but the parsed value was quoted too:

Expected: "-.q=blablablaG0"
But was: ""-.q=blablablaG0""

Should I remove quotes from the Param value manually? Is there any workaround besides this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant