Skip to content

Dash dash support in FormatCommandLine (unparser) #254

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

Closed
scadorel opened this issue Oct 12, 2015 · 4 comments
Closed

Dash dash support in FormatCommandLine (unparser) #254

scadorel opened this issue Oct 12, 2015 · 4 comments

Comments

@scadorel
Copy link
Contributor

Hello,

When using value options with dash inside some of them, the generated command line generated by the FormatCommandLine method is not correct.

    public class SimpleOptions
    {
        [Option("option1")]
        public string Option1 { get; set; }

        [Value(0, MetaName = "command")]
        public string Command { get; set; }

        [Value(1, MetaName = "arguments")]
        public IEnumerable<string> Arguments { get; set; }
    }

   var commandOpts = new SimpleOptions();
   commandOpts.Option1 = "test";
   commandOpts.Command = "powershell";
   commandOpts.Arguments = new List<string>() { "-version", "3.0", "D:\\test.ps1" };

   var result = parser.FormatCommandLine(commandOpts);

The sample with generate --option1 test powershell -version 3.0 D:\test.ps1 but "-version" switch will be detected by the library as an invalid option and will raise an error.
It might be good to use the dash dash syntax with the unparser to avoid the issue.
Expected result: --option1 test -- powershell -version 3.0 D:\test.ps1
What do you think ?

I will send a PR shortly.

@nemec
Copy link
Collaborator

nemec commented Oct 12, 2015

Good call. We don't escape arguments even though we should. However, I would like to point out that option1 will have a double dash in your expected output: --option1 test [...]

@scadorel
Copy link
Contributor Author

You're right, thanks. Missed a dash in the sample 👍
Fixed.

@scadorel
Copy link
Contributor Author

PR has been merged and validated. Closing issue.

@gsscoder
Copy link
Owner

gsscoder commented Nov 2, 2015

Thank you, @nemec and @scadorel, again.

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

3 participants