Skip to content

ExampleAttribute ​

Adds example input for a command class. ConsoleCommandDiscovery.GetAllCommands reads this attribute and combines the command name with the provided values to produce the Example value on ConsoleCommand.

Use this attribute when command listing or help output should show a realistic invocation instead of only the generated parameter usage string.

Usage ​

csharp
using AlmightyShogun.ConsoleCommands;

[Example("42")]
[ConsoleCommand("user", "Prints user information.")]
public sealed class UserCommand : ConsoleCommandBase
{
    public Task ExecuteAsync(int userId)
    {
        Console.WriteLine($"Loading user {userId}");

        return Task.CompletedTask;
    }
}

Parameters

args: object[]
Example arguments appended after the command name when metadata is generated.
Default: []

Type signature ​

csharp
public ExampleAttribute(params object[] args);

All packages are released under the MIT License.