* Make existing module commanders register as help topics

* Typing help will now give a list of these topics at the top (as well as the rest of the current help stuff)
* Typing help <topic> will give information about commands specific to that topic
This commit is contained in:
Justin Clarke Casey
2009-02-05 21:35:59 +00:00
parent 9a666bda02
commit 732cd838b1
10 changed files with 132 additions and 69 deletions

View File

@@ -52,6 +52,23 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
get { return m_name; }
}
private string m_name;
public string Help
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("===" + m_name + "===");
foreach (ICommand com in m_commands.Values)
{
sb.AppendLine("* " + com.Name + " - " + com.Help);
}
return sb.ToString();
}
}
/// <summary>
/// Constructor
@@ -60,7 +77,10 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
public Commander(string name)
{
m_name = name;
m_generatedApiClassName = m_name;
m_generatedApiClassName = m_name[0].ToString().ToUpper();
if (m_name.Length > 1)
m_generatedApiClassName += m_name.Substring(1);
}
/// <value>
@@ -145,22 +165,14 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
{
if (function != "help")
Console.WriteLine("ERROR: Invalid command - No such command exists");
ShowConsoleHelp();
Console.Write(Help);
}
}
}
#endregion
private void ShowConsoleHelp()
{
Console.WriteLine("===" + m_name + "===");
foreach (ICommand com in m_commands.Values)
{
Console.WriteLine("* " + com.Name + " - " + com.Help);
}
}
private string EscapeRuntimeAPICommand(string command)
{
command = command.Replace('-', '_');

View File

@@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
{
public class CommanderTestModule : IRegionModule, ICommandableModule
{
private readonly Commander m_commander = new Commander("CommanderTest");
private readonly Commander m_commander = new Commander("commandertest");
private Scene m_scene;
#region ICommandableModule Members