Skip to content

Interface ICommandService

Namespace: Void.Proxy.Api.Commands
Assembly: Void.Proxy.Api.dll

Provides access to command dispatching and execution operations.

public interface ICommandService

Extension Methods

CommandServiceExtensions.Register(ICommandService, Func<IArgumentContext, LiteralArgumentBuilder>)

Properties

Dispatcher

Gets the dispatcher used to route commands to their handlers.

ICommandDispatcher Dispatcher { get; }

Property Value

ICommandDispatcher

Methods

CopyToAsync(ICommandNode, ICommandSource, CancellationToken)

Copies commands available to a source into another root command node.

ValueTask CopyToAsync(ICommandNode commandNode, ICommandSource commandSource, CancellationToken cancellationToken = default)

Parameters

commandNode ICommandNode

The destination root command node.

commandSource ICommandSource

The source used to evaluate command requirements.

cancellationToken CancellationToken

A token used to cancel requirement evaluation.

Returns

ValueTask

A task that completes after all eligible commands have been copied.

Remarks

Existing destination children with the same names are replaced. Commands whose requirements reject commandSource are omitted.

Exceptions

ArgumentException

commandNode is not a root command node.

ExecuteAsync(ICommandSource, string, CancellationToken)

Executes a command on behalf of the specified source.

ValueTask<CommandExecutionResult> ExecuteAsync(ICommandSource source, string command, CancellationToken cancellationToken = default)

Parameters

source ICommandSource

The initiator of the command.

command string

The command string to execute.

cancellationToken CancellationToken

Token used to cancel the execution.

Returns

ValueTask<CommandExecutionResult>

A result describing the outcome of the command execution.

ExecuteAsync(ICommandSource, string, Side, CancellationToken)

Executes a command that originated from the specified origin.

ValueTask<CommandExecutionResult> ExecuteAsync(ICommandSource source, string command, Side origin, CancellationToken cancellationToken = default)

Parameters

source ICommandSource

The initiator of the command.

command string

The command string to execute.

origin Side

The side from which the command originated.

cancellationToken CancellationToken

Token used to cancel the execution.

Returns

ValueTask<CommandExecutionResult>

A result describing the outcome of the command execution.

SuggestAsync(string, ICommandSource, CancellationToken)

Completes the specified command input using available commands.

ValueTask<IEnumerable<ICommandSuggestion>> SuggestAsync(string input, ICommandSource source, CancellationToken cancellationToken = default)

Parameters

input string

The partial command to complete.

source ICommandSource

The initiator requesting completion suggestions.

cancellationToken CancellationToken

Token used to cancel the completion operation.

Returns

ValueTask<IEnumerable<ICommandSuggestion>>

An array of possible completions.