-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpCommand.cs
More file actions
38 lines (30 loc) · 1.35 KB
/
HelpCommand.cs
File metadata and controls
38 lines (30 loc) · 1.35 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
using NShell.Shell;
using NShell.Shell.Commands;
using Spectre.Console;
namespace NShell.Commands;
public class HelpCommand : ICustomCommand, IMetadataCommand
{
public string Name => "help";
public string Description => "Display help information about available commands.";
public void Execute(ShellContext context, string[] args)
{
AnsiConsole.MarkupLine("[bold cyan]NShell - Available Commands[/]\n");
var table = new Table();
table.AddColumn("[bold]Command[/]");
table.AddColumn("[bold]Description[/]");
// Add custom commands with descriptions
foreach (var cmd in CommandParser.CustomCommands.Values.OrderBy(c => c.Name))
{
string description = "No description available";
if (cmd is IMetadataCommand metaCmd)
{
description = metaCmd.Description;
}
table.AddRow($"[yellow]{cmd.Name}[/]", description);
}
AnsiConsole.Write(table);
AnsiConsole.MarkupLine($"\n[grey]Total custom commands: {CommandParser.CustomCommands.Count}[/]");
AnsiConsole.MarkupLine($"[grey]Total system commands: {CommandParser.SystemCommands.Count}[/]");
AnsiConsole.MarkupLine("\n[grey]Type a command name to execute it, or use Tab for auto-completion.[/]");
}
}