Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add unparse extension with args (string[]) as return value #628

Copy link
Copy link
@kapsiR

Description

@kapsiR
Issue body actions

It would be cool if I can use the unparsed string with the parser again.

e.g.

public static string[] FormatCommandLineArgs<T>(this Parser parser, T options, Action<UnParserSettings> configuration)

If the options instance is manually created, it would be possible to let commandline handle some default stuff:

        public async Task RunAsync(string[] args)
        {
            var parserResult = _parser.ParseArguments<MyOptions1, MyOptions2, MyOptions3>(args);

            await parserResult.MapResult(
                  async (MyOptions1 opts) => await Run1Async(opts),
                  async (MyOptions2 opts) => await Run2Async(opts),
                  async (MyOptions3 opts) => await Run3Async(opts),
                  async (IEnumerable<Error> errors) => await HandleParseErrorAsync(errors));
        }

        public async Task RunWithOptionsAsync<T>(T options)
        {
            string[] unparsedArgs = _parser.FormatCommandLineArgs(options);

            await RunAsync(unparsedArgs);
        }
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.