2007-04-28 20:54:02 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
|
|
|
|
public class HelpCommand: Command
|
|
|
|
|
{
|
|
|
|
|
public HelpCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "help";
|
2008-07-25 08:55:36 +00:00
|
|
|
Description = "Lists available commands. usage: help [command] to display information on commands";
|
|
|
|
|
Category = CommandCategory.TestClient;
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2008-07-25 08:55:36 +00:00
|
|
|
if (args.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
if (Client.Commands.ContainsKey(args[0]))
|
|
|
|
|
return Client.Commands[args[0]].Description;
|
|
|
|
|
else
|
|
|
|
|
return "Command " + args[0] + " Does not exist. \"help\" to display all available commands.";
|
|
|
|
|
}
|
2007-04-28 20:54:02 +00:00
|
|
|
StringBuilder result = new StringBuilder();
|
2008-07-25 08:55:36 +00:00
|
|
|
SortedDictionary<CommandCategory, List<Command>> CommandTree = new SortedDictionary<CommandCategory, List<Command>>();
|
|
|
|
|
|
|
|
|
|
CommandCategory cc;
|
2007-04-28 20:54:02 +00:00
|
|
|
foreach (Command c in Client.Commands.Values)
|
2022-02-25 19:38:11 -06:00
|
|
|
{
|
|
|
|
|
cc = c.Category.Equals(null) ? CommandCategory.Unknown : c.Category;
|
2008-07-25 08:55:36 +00:00
|
|
|
|
|
|
|
|
if (CommandTree.ContainsKey(cc))
|
|
|
|
|
CommandTree[cc].Add(c);
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-02-25 19:38:11 -06:00
|
|
|
List<Command> l = new List<Command> { c };
|
2008-07-25 08:55:36 +00:00
|
|
|
CommandTree.Add(cc, l);
|
|
|
|
|
}
|
2022-02-25 19:38:11 -06:00
|
|
|
}
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2008-07-25 08:55:36 +00:00
|
|
|
foreach (KeyValuePair<CommandCategory, List<Command>> kvp in CommandTree)
|
|
|
|
|
{
|
|
|
|
|
result.AppendFormat(System.Environment.NewLine + "* {0} Related Commands:" + System.Environment.NewLine, kvp.Key.ToString());
|
|
|
|
|
int colMax = 0;
|
2021-07-25 11:10:52 -05:00
|
|
|
foreach (var val in kvp.Value)
|
2008-07-25 08:55:36 +00:00
|
|
|
{
|
|
|
|
|
if (colMax >= 120)
|
|
|
|
|
{
|
|
|
|
|
result.AppendLine();
|
|
|
|
|
colMax = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-25 11:10:52 -05:00
|
|
|
result.AppendFormat(" {0,-15}", val.Name);
|
2008-07-25 08:55:36 +00:00
|
|
|
colMax += 15;
|
|
|
|
|
}
|
|
|
|
|
result.AppendLine();
|
|
|
|
|
}
|
|
|
|
|
result.AppendLine(System.Environment.NewLine + "Help [command] for usage/information");
|
|
|
|
|
|
2007-04-28 20:54:02 +00:00
|
|
|
return result.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|