2020-02-17 02:44:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace RecrownedGTK.Tools.CommandProcessor.Commands
|
|
|
|
|
{
|
2020-02-23 21:21:23 +00:00
|
|
|
|
public class HelpCommand : EngineCommand
|
2020-02-17 02:44:21 +00:00
|
|
|
|
{
|
|
|
|
|
CommandEngine commandEngine;
|
|
|
|
|
|
|
|
|
|
public HelpCommand(CommandEngine commandEngine) : base("help")
|
|
|
|
|
{
|
|
|
|
|
this.commandEngine = commandEngine;
|
|
|
|
|
help = "help [command] [arg]";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-02-24 01:51:39 +00:00
|
|
|
|
public override void Run(IUserInput userInput, IUserOutput userOutput, string[] arguments)
|
2020-02-17 02:44:21 +00:00
|
|
|
|
{
|
|
|
|
|
if (arguments != null)
|
|
|
|
|
{
|
|
|
|
|
if (commandEngine.ContainsCommand(arguments[0]))
|
|
|
|
|
{
|
2020-02-24 01:51:39 +00:00
|
|
|
|
if (arguments.Length < 2) userOutput.WrappedOutput(commandEngine.GetCommand(arguments[0]).Help(null));
|
2020-02-17 02:44:21 +00:00
|
|
|
|
for (int i = 1; i < arguments.Length; i++)
|
|
|
|
|
{
|
2020-02-24 01:51:39 +00:00
|
|
|
|
userOutput.WrappedOutput(commandEngine.GetCommand(arguments[0]).Help(arguments[i]));
|
2020-02-17 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException(arguments[0] + " not a command. Type \"help\" for a list of commands.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-02-24 01:51:39 +00:00
|
|
|
|
userOutput.WrappedOutput("Tools for RecrownedGTK library. Possible commands are as follows:\n");
|
2020-02-17 02:44:21 +00:00
|
|
|
|
foreach (EngineCommand engineCommand in commandEngine.commands)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < engineCommand.InvokeStrings.Length; i++)
|
|
|
|
|
{
|
2020-02-24 01:51:39 +00:00
|
|
|
|
userOutput.WrappedOutput(engineCommand.InvokeStrings[i]);
|
2020-02-17 02:44:21 +00:00
|
|
|
|
if (i + 1 < engineCommand.InvokeStrings.Length)
|
|
|
|
|
{
|
2020-02-24 01:51:39 +00:00
|
|
|
|
userOutput.WrappedOutput(", ");
|
2020-02-17 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-24 01:51:39 +00:00
|
|
|
|
userOutput.WrappedOutput(" : ");
|
|
|
|
|
userOutput.WrappedOutput(engineCommand.Help().Replace("\n", "\n\t"));
|
|
|
|
|
userOutput.WrappedOutput("\n");
|
|
|
|
|
userOutput.Output("--------");
|
2020-02-17 02:44:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|