Class CommandDescriptor
- Namespace
- Signal.Application.Commands
- Assembly
- Signal.Application.dll
Everything the framework knows about a command: metadata, parameters, preconditions and how to invoke it. Created by the registry from ICommand classes and CommandModule methods, or directly for delegate commands.
public sealed class CommandDescriptor
- Inheritance
-
CommandDescriptor
- Inherited Members
Constructors
CommandDescriptor(string, Func<CommandContext, object?[], Task>, Type, IEnumerable<string>?, string?, string?, IEnumerable<CommandParameter>?, IEnumerable<PreconditionAttribute>?, bool, MethodInfo?)
Creates a descriptor.
public CommandDescriptor(string name, Func<CommandContext, object?[], Task> executor, Type declaringType, IEnumerable<string>? aliases = null, string? description = null, string? usage = null, IEnumerable<CommandParameter>? parameters = null, IEnumerable<PreconditionAttribute>? preconditions = null, bool hidden = false, MethodInfo? method = null)
Parameters
namestringThe command name (no whitespace).
executorFunc<CommandContext, object[], Task>Invokes the command with the bound values (in
parametersorder).declaringTypeTypeThe type that defines the command (used in diagnostics).
aliasesIEnumerable<string>Alternative names.
descriptionstringOne-line description for help.
usagestringCustom usage text without prefix.
parametersIEnumerable<CommandParameter>Bindable parameters.
preconditionsIEnumerable<PreconditionAttribute>Checks to run before execution; sorted by Order.
hiddenboolHide from the help listing.
methodMethodInfoThe command method for module commands.
Exceptions
- ArgumentException
nameis empty or contains whitespace.
Properties
Aliases
Alternative names.
public IReadOnlyList<string> Aliases { get; }
Property Value
Category
The help heading from CategoryAttribute, if any.
public string? Category { get; init; }
Property Value
DeclaringType
The type that defines the command.
public Type DeclaringType { get; }
Property Value
Description
One-line description for help.
public string? Description { get; }
Property Value
Examples
Example invocations without prefix, from ExampleAttribute.
public IReadOnlyList<string> Examples { get; init; }
Property Value
Executor
Invokes the command with the bound parameter values (in Parameters order).
public Func<CommandContext, object?[], Task> Executor { get; }
Property Value
- Func<CommandContext, object[], Task>
FullName
The name as typed after the prefix: group name for grouped commands, otherwise Name.
public string FullName { get; }
Property Value
Group
The group the command belongs to, or null for a top-level command.
public CommandGroupInfo? Group { get; init; }
Property Value
Hidden
Whether the command is hidden from the help listing.
public bool Hidden { get; }
Property Value
Method
The command method for module commands; null otherwise.
public MethodInfo? Method { get; }
Property Value
Name
The command name (within its Group, if any).
public string Name { get; }
Property Value
Parameters
Bindable parameters in declaration order.
public IReadOnlyList<CommandParameter> Parameters { get; }
Property Value
Preconditions
Preconditions in execution order.
public IReadOnlyList<PreconditionAttribute> Preconditions { get; }
Property Value
Usage
Custom usage text without prefix, or null to generate it.
public string? Usage { get; }
Property Value
Methods
FormatUsage(string)
Formats the usage line, e.g. /add <a> <b> or /playlist add <song...>.
public string FormatUsage(string prefix)
Parameters
prefixstringThe prefix to show (usually the one the user typed).
Returns
- string
The usage line.
ToString()
Returns FullName.
public override string ToString()
Returns
- string
The command name, including the group.