* Implement help <command> from the region console

* So at the moment once can type 'help terrain fill' as well as 'terrain fill help'
* Current implementation is a transient hack that should be tidied up soon
0.6.3-post-fixes
Justin Clarke Casey 2009-02-06 18:18:01 +00:00
parent 9b66108081
commit 00a3cbd6fa
4 changed files with 73 additions and 11 deletions

View File

@ -712,10 +712,25 @@ namespace OpenSim
}
else
{
ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(helpArgs[0]);
if (moduleCommander != null)
// Messily we want to join all the help params back here
//string helpSubject = string.Join(" ", helpArgs);
// FIXME: Very cheap hack to get transition help working. Will disappear very shortly.
if (helpArgs.Length == 1)
{
m_console.Notice(moduleCommander.Help);
ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(helpArgs[0]);
if (moduleCommander != null)
{
m_console.Notice(moduleCommander.Help);
}
}
else
{
ICommand command = SceneManager.CurrentOrFirstScene.GetCommand(helpArgs[1]);
if (command != null)
{
m_console.Notice(command.Help);
}
}
}
}

View File

@ -59,7 +59,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("===" + m_name + "===");
sb.AppendLine("=== " + m_name + " ===");
foreach (ICommand com in m_commands.Values)
{
@ -83,9 +83,6 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
m_generatedApiClassName += m_name.Substring(1);
}
/// <value>
/// Commands that this commander knows about
/// </value>
public Dictionary<string, ICommand> Commands
{
get { return m_commands; }

View File

@ -25,6 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace OpenSim.Region.Framework.Interfaces
{
public interface ICommander
@ -39,6 +41,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// </value>
string Help { get; }
/// <summary>
/// The commands available for this commander
/// </summary>
Dictionary<string, ICommand> Commands { get; }
void ProcessConsoleCommand(string function, string[] args);
void RegisterCommand(string commandName, ICommand command);
void Run(string function, object[] args);

View File

@ -61,17 +61,24 @@ namespace OpenSim.Region.Framework.Scenes
/// <value>
/// The module interfaces available from this scene.
/// </value>
protected Dictionary<Type, List<object> > ModuleInterfaces = new Dictionary<Type, List<object> >();
protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>();
protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
/// <value>
/// The module commanders available from this scene
/// </value>
protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
/// <value>
/// The module commands available for this scene
/// </value>
protected Dictionary<string, ICommand> m_moduleCommands = new Dictionary<string, ICommand>();
/// <value>
/// Registered classes that are capable of creating entities.
/// </value>
protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>();
//API module interfaces
protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>();
/// <summary>
/// The last allocated local prim id. When a new local id is requested, the next number in the sequence is
@ -278,11 +285,47 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Register a module commander.
/// </summary>
/// <param name="commander"></param>
public void RegisterModuleCommander(ICommander commander)
{
lock (m_moduleCommanders)
{
m_moduleCommanders.Add(commander.Name, commander);
lock (m_moduleCommands)
{
foreach (ICommand command in commander.Commands.Values)
{
if (m_moduleCommands.ContainsKey(command.Name))
{
m_log.ErrorFormat(
"[MODULES]: Module commander {0} tried to register the command {1} which has already been registered",
commander.Name, command.Name);
continue;
}
m_moduleCommands[command.Name] = command;
}
}
}
}
/// <summary>
/// Get an available module command
/// </summary>
/// <param name="commandName"></param>
/// <returns>The command if it was found, null if no command is available with that name</returns>
public ICommand GetCommand(string commandName)
{
lock (m_moduleCommands)
{
if (m_moduleCommands.ContainsKey(commandName))
return m_moduleCommands[commandName];
else
return null;
}
}