Skip to content

Unparsing into string array #665

Closed
Closed

Description

@buddhikac96

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?

Activity

  1. moh-hassan commented on Jul 14, 2020

    @moh-hassan
    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
    
  2. buddhikac96 commented on Jul 14, 2020

    @buddhikac96
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions