Skip to content

AliasAttribute ​

Adds one or more aliases to a command class, so a short form or a retired name keeps working without a second class. ConsoleCommandHandler maps each alias to the same command type as the name on ConsoleCommandAttribute, matching case-insensitively.

An alias already claimed by another command is dropped with a warning, so the first registration keeps the name.

Usage ​

csharp
using AlmightyShogun.ConsoleCommands;

[Alias("stop", "quit")]
[ConsoleCommand("shutdown", "Stops the application.")]
public sealed class ShutdownCommand : ConsoleCommandBase
{
    public Task ExecuteAsync()
    {
        Console.WriteLine("Stopping...");

        return Task.CompletedTask;
    }
}

Parameters

aliases: string[]
Alternative command names that resolve to the same command class, matched case-insensitively like the command name.
Default: []

Type signature ​

csharp
public AliasAttribute(params string[] aliases);

All packages are released under the MIT License.