Skip to content

Argument param value not passed to CommandHandler #1326

@bradykelly

Description

@bradykelly

I have the following parsing code:

        public void Run(string[] cliArgs)
        {
            var rootCommand = new RootCommand
            {
                new Argument<string>("table", "The name of a DB table to create DAL artifacts for"),
                new Option<string>(new[] {"-m", "--model"}, "The name of an existing DAL model to create the table artifacts for"),
                new Option(new[] {"-o", "--overwrite"}, "Update the list of models and tables from the DAL")
            };

            rootCommand.Handler = CommandHandler.Create<string, string, bool, IConsole>(CreateTableArtifacts);
            rootCommand.Invoke(cliArgs);
        }

Where cliArgs is an array with one non-empty string value. Then I have my command handler with signature:

private void CreateTableArtifacts(string tableName, string? modelName, bool overwrite, IConsole console)

But inside the handler, the tableName param has the empty string value. Why is this?

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