Skip to content

Commit 8e7d652

Browse files
committed
added HelpCommand meta
1 parent fcdafad commit 8e7d652

10 files changed

Lines changed: 51 additions & 3 deletions

File tree

src/ScriptCs.Contracts/IReplCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
public interface IReplCommand
44
{
5+
string Description { get; }
6+
57
string CommandName { get; }
68

79
object Execute(IScriptExecutor repl, object[] args);

src/ScriptCs.Core/ReplCommands/CdCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ namespace ScriptCs.ReplCommands
55
{
66
public class CdCommand : IReplCommand
77
{
8+
public string Description
9+
{
10+
get { return "Changes the working directory to the path provided."; }
11+
}
12+
813
public string CommandName
914
{
1015
get { return "cd"; }

src/ScriptCs.Core/ReplCommands/ClearCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ public class ClearCommand : IReplCommand
66
{
77
private readonly IConsole _console;
88

9+
public string Description
10+
{
11+
get { return "Clears the console window."; }
12+
}
13+
914
public ClearCommand(IConsole console)
1015
{
1116
Guard.AgainstNullArgument("console", console);

src/ScriptCs.Core/ReplCommands/CwdCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public CwdCommand(IConsole console)
1414
_console = console;
1515
}
1616

17+
public string Description
18+
{
19+
get { return "Displays the current working directory."; }
20+
}
21+
1722
public string CommandName
1823
{
1924
get { return "cwd"; }

src/ScriptCs.Core/ReplCommands/HelpCommand.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ScriptCs.Contracts;
1+
using System.Linq;
2+
using ScriptCs.Contracts;
23

34
namespace ScriptCs.ReplCommands
45
{
@@ -11,6 +12,11 @@ public HelpCommand(IConsole console)
1112
_console = console;
1213
}
1314

15+
public string Description
16+
{
17+
get { return "Shows this help."; }
18+
}
19+
1420
public string CommandName
1521
{
1622
get { return "help"; }
@@ -22,9 +28,9 @@ public object Execute(IScriptExecutor repl, object[] args)
2228
if (typedRepl != null)
2329
{
2430
_console.WriteLine("The following commands are available in the REPL:");
25-
foreach (var command in typedRepl.Commands)
31+
foreach (var command in typedRepl.Commands.OrderBy(x => x.CommandName))
2632
{
27-
_console.WriteLine(string.Format(":{0}", command.CommandName));
33+
_console.WriteLine(string.Format(":{0,-15}{1,10}", command.CommandName, command.Description));
2834
}
2935
}
3036

src/ScriptCs.Core/ReplCommands/InstallCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public InstallCommand(
3030
_installationProvider = installationProvider;
3131
}
3232

33+
public string Description
34+
{
35+
get { return "Installs a Nuget package. I.e. :install <package> <version>"; }
36+
}
37+
3338
public string CommandName
3439
{
3540
get { return "install"; }

src/ScriptCs.Core/ReplCommands/ReferencesCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public string CommandName
1010
get { return "references"; }
1111
}
1212

13+
public string Description
14+
{
15+
get { return "Displays a list of assemblies referenced from the REPL context."; }
16+
}
17+
1318
public object Execute(IScriptExecutor repl, object[] args)
1419
{
1520
if (repl.References != null)

src/ScriptCs.Core/ReplCommands/ResetCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ namespace ScriptCs.ReplCommands
44
{
55
public class ResetCommand : IReplCommand
66
{
7+
public string Description
8+
{
9+
get { return "Resets the REPL state. All local variables and member definitions are cleared."; }
10+
}
11+
712
public string CommandName
813
{
914
get { return "reset"; }

src/ScriptCs.Core/ReplCommands/UsingsCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ namespace ScriptCs.ReplCommands
44
{
55
public class UsingsCommand : IReplCommand
66
{
7+
public string Description
8+
{
9+
get { return "Displays a list of namespaces imported into REPL context."; }
10+
}
11+
712
public string CommandName
813
{
914
get { return "usings"; }

src/ScriptCs.Core/ReplCommands/VarsCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ public string CommandName
99
get { return "vars"; }
1010
}
1111

12+
public string Description
13+
{
14+
get { return "Displays a list of variables defined within the REPL, along with their types and values."; }
15+
}
16+
1217
public object Execute(IScriptExecutor repl, object[] args)
1318
{
1419
var replEngine = repl.ScriptEngine as IReplEngine;

0 commit comments

Comments
 (0)