From 749c3fef8ad2d3af97fcd9ab9c72740675e46715 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Mar 2012 01:51:37 +0000 Subject: Change "help" to display categories/module list then "help " to display commands in a category. This is to deal with the hundred lines of command splurge when one previously typed "help" Modelled somewhat on the mysql console One can still type help to get per command help at any point. Categories capitalized to avoid conflict with the all-lowercase commands (except for commander system, as of yet). Does not affect command parsing or any other aspects of the console apart from the help system. Backwards compatible with existing modules. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 71 +++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 11e5ce3..ecadd24 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -596,7 +596,7 @@ namespace OpenSim.Region.Framework.Scenes #endregion Region Settings - MainConsole.Instance.Commands.AddCommand("region", false, "reload estate", + MainConsole.Instance.Commands.AddCommand("estate", false, "reload estate", "reload estate", "Reload the estate data", HandleReloadEstate); diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 712e094..495cede 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -472,6 +472,63 @@ namespace OpenSim.Region.Framework.Scenes /// /// Call this from a region module to add a command to the OpenSim console. /// + /// + /// The use of IRegionModuleBase is a cheap trick to get a different method signature, + /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// + /// + /// + /// + /// + public void AddCommand( + string category, object mod, string command, string shorthelp, string longhelp, CommandDelegate callback) + { + AddCommand(category, mod, command, shorthelp, longhelp, string.Empty, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// + /// + /// + /// + /// + public void AddCommand(object mod, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + { + string moduleName = ""; + + if (mod != null) + { + if (mod is IRegionModule) + { + IRegionModule module = (IRegionModule)mod; + moduleName = module.Name; + } + else if (mod is IRegionModuleBase) + { + IRegionModuleBase module = (IRegionModuleBase)mod; + moduleName = module.Name; + } + else + { + throw new Exception("AddCommand module parameter must be IRegionModule or IRegionModuleBase"); + } + } + + AddCommand(moduleName, mod, command, shorthelp, longhelp, descriptivehelp, callback); + } + + /// + /// Call this from a region module to add a command to the OpenSim console. + /// + /// + /// Category of the command. This is the section under which it will appear when the user asks for help + /// /// /// /// @@ -479,12 +536,12 @@ namespace OpenSim.Region.Framework.Scenes /// /// public void AddCommand( - object mod, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) + string category, object mod, string command, + string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) { if (MainConsole.Instance == null) return; - string modulename = String.Empty; bool shared = false; if (mod != null) @@ -492,20 +549,20 @@ namespace OpenSim.Region.Framework.Scenes if (mod is IRegionModule) { IRegionModule module = (IRegionModule)mod; - modulename = module.Name; shared = module.IsSharedModule; } else if (mod is IRegionModuleBase) { - IRegionModuleBase module = (IRegionModuleBase)mod; - modulename = module.Name; shared = mod is ISharedRegionModule; } - else throw new Exception("AddCommand module parameter must be IRegionModule or IRegionModuleBase"); + else + { + throw new Exception("AddCommand module parameter must be IRegionModule or IRegionModuleBase"); + } } MainConsole.Instance.Commands.AddCommand( - modulename, shared, command, shorthelp, longhelp, descriptivehelp, callback); + category, shared, command, shorthelp, longhelp, descriptivehelp, callback); } public virtual ISceneObject DeserializeObject(string representation) -- cgit v1.1