Skip to content

ConsoleCommand ​

The metadata describing one discovered command, built by ConsoleCommandDiscovery.GetAllCommands from a command class's attributes and ExecuteAsync parameters. It is a read model, so holding one never constructs the class it came from. Instances come only from that method.

Usage ​

csharp
using AlmightyShogun.ConsoleCommands;

foreach (ConsoleCommand command in ConsoleCommandDiscovery.GetAllCommands())
{
    string description = command.Description ?? string.Empty;

    Console.WriteLine($"{command.Usage} - {description}");
}

Fields

Name: string
The name the command is invoked by, which is also what Usage and Example are prefixed with.

Description: string?
The explanation for a listing, or null when the command was declared without one.

Aliases: IReadOnlyList<string>
The extra names the command answers to, from AliasAttribute. Empty when it declares none.

Usage: string
The full line to type, as the name followed by one <name:Type> placeholder per handler parameter, excluding a trailing CancellationToken, which the dispatcher supplies. A command with nothing left to show yields the bare name.

Example: string?
A complete sample invocation from ExampleAttribute, including the command name, or null when the command declares none.

All packages are released under the MIT License.