-
Notifications
You must be signed in to change notification settings - Fork 1
/
HelpCommand.cs
35 lines (31 loc) · 1.06 KB
/
HelpCommand.cs
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
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace nvma
{
/// <summary>
/// Command that returns all commands
/// </summary>
class HelpCommand : CustomCommand
{
public override Task Execute(string[] args)
{
return Task.Run(() =>
{
var commandInterfaceType = typeof(CustomCommand);
var availableCommands = Assembly.GetExecutingAssembly()
.GetTypes()
.Where(
commandType =>
commandInterfaceType.IsAssignableFrom(commandType) && !commandType.IsAbstract
).Select(command => command.Name.Replace("Command", "").ToLower() + ": " + ((ICustomCommand)Activator.CreateInstance(command)).ToString());
Console.WriteLine(string.Join('\n', availableCommands));
});
}
public override string ToString()
{
return "Returns all possible commands and their usages";
}
}
}