Skip to content

Allow adding aliases to command using object initializer #1262

Open
@CCRcmcpe

Description

@CCRcmcpe

This is a simple example:

var rootCommand = new RootCommand
{
    new Command("do-something")
    {
        new Command("abcdefg") // How to add aliases here?
        new Command("qwerty")
    }
};

In this case, you have to give up using the object initializer and manually add the commands.
This supposed example demonstrates an easy way to build commands.

var rootCommand = new RootCommand
{
    new Command("do-something")
    {
        new Command("abcdefg") { Aliases = { "c", "w" } } // In reality, this will raise a compiler error, because Aliases is a IReadOnlyList<string>
        new Command("qwerty")
    }
};

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