37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System;
|
|
using YourProject.Commands; // Reference the namespace
|
|
|
|
namespace YourProject.Commands
|
|
{
|
|
public class HelpCommand : Command
|
|
{
|
|
public override string Name => "help";
|
|
public override string Description => "Shows available commands";
|
|
public override string Usage => "help [command]";
|
|
|
|
public override void Execute(string[] args, Action<string> outputCallback)
|
|
{
|
|
if (args.Length > 0)
|
|
{
|
|
var command = ConsoleManager.GetCommand(args[0]);
|
|
if (command != null)
|
|
{
|
|
outputCallback($"{command.Name} - {command.Description}");
|
|
outputCallback($"Usage: {command.Usage}");
|
|
}
|
|
else
|
|
{
|
|
outputCallback($"Unknown command: {args[0]}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
outputCallback("Available commands:");
|
|
foreach (var cmd in ConsoleManager.GetAllCommands())
|
|
{
|
|
outputCallback($" {cmd.Name,-10} - {cmd.Description}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |