mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-10-25 15:19:23 +00:00
Also raise CA2016 (forward the CancellationToken parameter to methods that take one) to warning Fixes #701
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
namespace Spectre.Console.Cli;
|
|
|
|
/// <summary>
|
|
/// Base class for an asynchronous command with no settings.
|
|
/// </summary>
|
|
public abstract class AsyncCommand : ICommand<EmptyCommandSettings>
|
|
{
|
|
/// <summary>
|
|
/// Executes the command.
|
|
/// </summary>
|
|
/// <param name="context">The command context.</param>
|
|
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to abort the command.</param>
|
|
/// <returns>An integer indicating whether or not the command executed successfully.</returns>
|
|
public abstract Task<int> ExecuteAsync(CommandContext context, CancellationToken cancellationToken);
|
|
|
|
/// <inheritdoc/>
|
|
Task<int> ICommand<EmptyCommandSettings>.ExecuteAsync(CommandContext context, EmptyCommandSettings settings, CancellationToken cancellationToken)
|
|
{
|
|
return ExecuteAsync(context, cancellationToken);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
Task<int> ICommand.ExecuteAsync(CommandContext context, CommandSettings settings, CancellationToken cancellationToken)
|
|
{
|
|
return ExecuteAsync(context, cancellationToken);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
ValidationResult ICommand.Validate(CommandContext context, CommandSettings settings)
|
|
{
|
|
return ValidationResult.Success();
|
|
}
|
|
} |