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

Unparsing into string array #665

Closed
buddhikac96 opened this issue Jul 12, 2020 · 2 comments
Closed

Unparsing into string array #665

buddhikac96 opened this issue Jul 12, 2020 · 2 comments
Labels

Comments

@buddhikac96
Copy link

In the project I am working there is a method which need command line arguments as a string array which I can't change. So how to unparse into string array.
I can get a string by unparsing using var arguments = Parser.Default.FormatCommandLine(Program.cliOption).

But my argument will be something like this.
app install --path "c:/My folder/app" --validate = false

So if I use above workaround I can't use string.Split(' ') since it possible to contains spaces in file paths. So is there any workaround to get string array from the object?

@moh-hassan
Copy link
Collaborator

The develop branch contain a new method FormatCommandLineArgs that generate array of strings.
You can download the package LineParser.2.8.0-ci-176.nupkg from CI server.
This feature will be available in v2.9

var options = new Options { FilePath = "c:/My folder/app", Validate = false };
string[] arguments = Parser.Default.FormatCommandLineArgs(options);

Output array:

--path
c:/My folder/app

@buddhikac96
Copy link
Author

@moh-hassan answer is clear. Thank you so much and closing the Issue.

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

No branches or pull requests

2 participants