Skip to content

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

Open
@oleksabor

Description

@oleksabor

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions