-
Notifications
You must be signed in to change notification settings - Fork 0
/
Help.cs
25 lines (22 loc) · 843 Bytes
/
Help.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
namespace YourNamespace;
public class Help : ICommand {
public string ShortHelp => "Shows this text";
public async Task Execute(Program Main, string Params) {
string[] Names = Main.Commands.Keys.OrderBy(T => T).ToArray();
if (Params.Length > 0) {
if (Main.Commands.TryGetValue(Params, out ICommand C)) {
Console.WriteLine($"Displaying help for: {Params[0]}");
C.GetHelp();
} else {
Console.WriteLine($"Command {Params[0]} not found");
}
} else {
Console.WriteLine($"Listing Commands: ");
foreach (string N in Names) {
if (Main.Commands.TryGetValue(N, out ICommand C)) {
Console.WriteLine($"{N}: {C.ShortHelp}");
}
}
}
}
}