forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpCommand.cs
More file actions
40 lines (32 loc) · 985 Bytes
/
HelpCommand.cs
File metadata and controls
40 lines (32 loc) · 985 Bytes
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
using System.Linq;
using ScriptCs.Contracts;
namespace ScriptCs.ReplCommands
{
public class HelpCommand : IReplCommand
{
private readonly IConsole _console;
public HelpCommand(IConsole console)
{
Guard.AgainstNullArgument("console", console);
_console = console;
}
public string Description
{
get { return "Shows this help."; }
}
public string CommandName
{
get { return "help"; }
}
public object Execute(IRepl repl, object[] args)
{
Guard.AgainstNullArgument("repl", repl);
_console.WriteLine("The following commands are available in the REPL:");
foreach (var command in repl.Commands.OrderBy(x => x.Key))
{
_console.WriteLine(string.Format(":{0,-15}{1,10}", command.Key, command.Value.Description));
}
return null;
}
}
}