mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-20 05:48:14 +08:00
Use file scoped namespace declarations
This commit is contained in:

committed by
Phil Scott

parent
1dbaf50935
commit
ec1188b837
@ -2,52 +2,51 @@ using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Spectre.Console.Cli
|
||||
namespace Spectre.Console.Cli;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for a command.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSettings">The settings type.</typeparam>
|
||||
/// <seealso cref="AsyncCommand{TSettings}"/>
|
||||
public abstract class Command<TSettings> : ICommand<TSettings>
|
||||
where TSettings : CommandSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for a command.
|
||||
/// Validates the specified settings and remaining arguments.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSettings">The settings type.</typeparam>
|
||||
/// <seealso cref="AsyncCommand{TSettings}"/>
|
||||
public abstract class Command<TSettings> : ICommand<TSettings>
|
||||
where TSettings : CommandSettings
|
||||
/// <param name="context">The command context.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns>The validation result.</returns>
|
||||
public virtual ValidationResult Validate([NotNull] CommandContext context, [NotNull] TSettings settings)
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates the specified settings and remaining arguments.
|
||||
/// </summary>
|
||||
/// <param name="context">The command context.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns>The validation result.</returns>
|
||||
public virtual ValidationResult Validate([NotNull] CommandContext context, [NotNull] TSettings settings)
|
||||
{
|
||||
return ValidationResult.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// </summary>
|
||||
/// <param name="context">The command context.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns>An integer indicating whether or not the command executed successfully.</returns>
|
||||
public abstract int Execute([NotNull] CommandContext context, [NotNull] TSettings settings);
|
||||
|
||||
/// <inheritdoc/>
|
||||
ValidationResult ICommand.Validate(CommandContext context, CommandSettings settings)
|
||||
{
|
||||
return Validate(context, (TSettings)settings);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
Task<int> ICommand.Execute(CommandContext context, CommandSettings settings)
|
||||
{
|
||||
Debug.Assert(settings is TSettings, "Command settings is of unexpected type.");
|
||||
return Task.FromResult(Execute(context, (TSettings)settings));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
Task<int> ICommand<TSettings>.Execute(CommandContext context, TSettings settings)
|
||||
{
|
||||
return Task.FromResult(Execute(context, settings));
|
||||
}
|
||||
return ValidationResult.Success();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// </summary>
|
||||
/// <param name="context">The command context.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns>An integer indicating whether or not the command executed successfully.</returns>
|
||||
public abstract int Execute([NotNull] CommandContext context, [NotNull] TSettings settings);
|
||||
|
||||
/// <inheritdoc/>
|
||||
ValidationResult ICommand.Validate(CommandContext context, CommandSettings settings)
|
||||
{
|
||||
return Validate(context, (TSettings)settings);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
Task<int> ICommand.Execute(CommandContext context, CommandSettings settings)
|
||||
{
|
||||
Debug.Assert(settings is TSettings, "Command settings is of unexpected type.");
|
||||
return Task.FromResult(Execute(context, (TSettings)settings));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
Task<int> ICommand<TSettings>.Execute(CommandContext context, TSettings settings)
|
||||
{
|
||||
return Task.FromResult(Execute(context, settings));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user