Skip to content

Getting the "current" verb #160

@ericnewton76

Description

@ericnewton76

Issue by jeffeld
Wednesday Aug 23, 2017 at 10:56 GMT
Originally opened as gsscoder/commandline#471


In the code below, I'd like to be able to either:

  • Pass the parsed verb to RunTask or
  • Retrieve the verb in RunTask

Is either one or both possible using 2.1.1-beta?

Thanks,
Jeff

`
static int Main(string[] args)
{

        int exitCode = CommandLine.Parser.Default.ParseArguments<AuditorOpinionScanOptions, TestTaskOptions>(args)
            .MapResult(
                (AuditorOpinionScanOptions options) => RunTask<AuditorOpinionScanTask, AuditorOpinionScanOptions>(options),
                (TestTaskOptions options) => RunTask<TestTask, TestTaskOptions>(options),
                errs => 1
            );

        


        return exitCode;

    }


    private static int RunTask<TTask, TOptions>(TOptions options) where TTask: ITask<TOptions>, new()
    {
        TTask task = new TTask()
        {
            Log = CreateLogger(),
            Options = options
        };

        return task.Execute();
    }

`

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