2018-12-09 06:51:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|
|
|
|
{
|
|
|
|
|
internal class HelpCommand : EngineCommand
|
|
|
|
|
{
|
|
|
|
|
CommandEngine commandEngine;
|
|
|
|
|
|
|
|
|
|
public HelpCommand(CommandEngine commandEngine) : base("help")
|
|
|
|
|
{
|
|
|
|
|
this.commandEngine = commandEngine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Help(string argument)
|
|
|
|
|
{
|
2018-12-09 07:10:18 +00:00
|
|
|
|
return "help [command] [arg]";
|
2018-12-09 06:51:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void Run(string[] arguments)
|
|
|
|
|
{
|
|
|
|
|
if (arguments != null)
|
|
|
|
|
{
|
|
|
|
|
if (commandEngine.ContainsCommand(arguments[0]))
|
|
|
|
|
{
|
|
|
|
|
ConsoleUtilities.WriteWrappedLine(commandEngine.GetCommand(arguments[0]).Help(null));
|
2018-12-09 07:10:18 +00:00
|
|
|
|
for (int i = 1; i < arguments.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ConsoleUtilities.WriteWrappedLine(commandEngine.GetCommand(arguments[0]).Help(arguments[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2018-12-09 06:51:33 +00:00
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException(arguments[0] + " not a command. Type \"help\" for a list of commands.");
|
|
|
|
|
}
|
2018-12-09 07:10:18 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-12-09 06:51:33 +00:00
|
|
|
|
{
|
|
|
|
|
ConsoleUtilities.WriteWrappedLine("Tools for RecrownedAthenaeum library. Possible commands are as follows:\n");
|
|
|
|
|
foreach (EngineCommand engineCommand in commandEngine.commands)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < engineCommand.invokeStrings.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ConsoleUtilities.WriteWrapped(engineCommand.invokeStrings[i]);
|
|
|
|
|
if (i + 1 < engineCommand.invokeStrings.Length)
|
|
|
|
|
{
|
|
|
|
|
ConsoleUtilities.WriteWrapped(", ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ConsoleUtilities.WriteWrapped(" : ");
|
|
|
|
|
ConsoleUtilities.WriteWrapped(engineCommand.Help().Replace("\n", "\n\t"), true);
|
2018-12-09 06:55:51 +00:00
|
|
|
|
Console.WriteLine("--------");
|
2018-12-09 06:51:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|