-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleCommand.cs
More file actions
50 lines (45 loc) · 1.37 KB
/
ModuleCommand.cs
File metadata and controls
50 lines (45 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using CliFx;
using CliFx.Infrastructure;
namespace Modulight.Modules.CommandLine
{
/// <summary>
/// Command of module.
/// </summary>
public abstract class ModuleCommand : ICommand
{
/// <summary>
///
/// </summary>
protected ModuleCommand()
{
}
/// <inheritdoc/>
public ValueTask ExecuteAsync(IConsole console) => ExecuteAsync(console, console.RegisterCancellationHandler());
/// <summary>
/// Executes the command using the specified implementation of <see cref="IConsole"/>.
/// </summary>
/// <param name="console"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
protected abstract ValueTask ExecuteAsync(IConsole console, CancellationToken cancellationToken = default);
}
/// <summary>
/// Command of module.
/// </summary>
/// <typeparam name="TModule"></typeparam>
public abstract class ModuleCommand<TModule> : ModuleCommand where TModule : ICommandLineModule
{
/// <summary>
///
/// </summary>
/// <param name="module"></param>
protected ModuleCommand(TModule module) : base()
{
Module = module;
}
/// <summary>
/// Module
/// </summary>
protected TModule Module { get; }
}
}