Replace the console for all OpenSim apps with a new console featuring command

line editing, context sensitive help (press ? at any time), command line
history, a new plugin command system and new appender features thet let you
type while the console is scrolling. Seamlessly integrates the ICommander
interfaces.
This commit is contained in:
Melanie Thielker
2009-02-07 12:25:39 +00:00
parent 4d4402158e
commit 54c6a920ba
23 changed files with 1499 additions and 1063 deletions

View File

@@ -34,6 +34,7 @@ using log4net.Config;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim
{
@@ -46,6 +47,8 @@ namespace OpenSim
public static bool m_saveCrashDumps = false;
public static string m_crashDir = "crashes";
protected static OpenSimBase m_sim = null;
//could move our main function into OpenSimMain and kill this class
public static void Main(string[] args)
{
@@ -93,18 +96,18 @@ namespace OpenSim
if (background)
{
OpenSimBase sim = new OpenSimBackground(configSource);
sim.Startup();
m_sim = new OpenSimBackground(configSource);
m_sim.Startup();
}
else
{
OpenSimBase sim = null;
m_sim = null;
if (hgrid)
sim = new HGOpenSimNode(configSource);
m_sim = new HGOpenSimNode(configSource);
else
sim = new OpenSim(configSource);
m_sim = new OpenSim(configSource);
sim.Startup();
m_sim.Startup();
while (true)
{

View File

@@ -77,6 +77,9 @@ namespace OpenSim
m_log.Info("====================================================================");
base.StartupSpecific();
MainConsole.Instance.Commands.AddCommand("hypergrid", "link-mapping", "link-mapping [<x> <y>] <cr>", "Set local coordinate to map HG regions to", RunCommand);
MainConsole.Instance.Commands.AddCommand("hypergrid", "link-region", "link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> <cr>", "Link a hypergrid region", RunCommand);
}
protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder)
@@ -143,11 +146,18 @@ namespace OpenSim
m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
}
public override void RunCmd(string command, string[] cmdparams)
public void RunCommand(string module, string[] cp)
{
List<string> cmdparams = new List<string>(cp);
if (cmdparams.Count < 1)
return;
string command = cmdparams[0];
cmdparams.RemoveAt(0);
if (command.Equals("link-mapping"))
{
if (cmdparams.Length == 2)
if (cmdparams.Count == 2)
{
try
{
@@ -166,11 +176,11 @@ namespace OpenSim
else if (command.Equals("link-region"))
{
// link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName>
if (cmdparams.Length < 4)
if (cmdparams.Count < 4)
{
if ((cmdparams.Length == 1) || (cmdparams.Length ==2))
if ((cmdparams.Count == 1) || (cmdparams.Count ==2))
{
LoadXmlLinkFile(cmdparams);
LoadXmlLinkFile(cmdparams.ToArray());
}
else
{
@@ -201,19 +211,16 @@ namespace OpenSim
if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
{
if (cmdparams.Length >= 5)
if (cmdparams.Count >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
for (int i = 4; i < cmdparams.Count; i++)
regInfo.RegionName += cmdparams[i] + " ";
}
}
return;
}
base.RunCmd(command, cmdparams);
}
private void LoadXmlLinkFile(string[] cmdparams)

File diff suppressed because it is too large Load Diff

View File

@@ -198,6 +198,46 @@ namespace OpenSim
// Only enable logins to the regions once we have completely finished starting up (apart from scripts)
m_commsManager.GridService.RegionLoginsEnabled = true;
List<string> topics = GetHelpTopics();
foreach (string topic in topics)
{
m_console.Commands.AddCommand("plugin", "help "+topic,
"help "+topic,
"Get help on plugin command '"+topic+"'",
HandleCommanderHelp);
m_console.Commands.AddCommand("plugin", topic,
topic,
"Execute subcommand for plugin '"+topic+"'",
null);
ICommander commander =
SceneManager.CurrentOrFirstScene.GetCommanders()[topic];
if (commander == null)
continue;
foreach (string command in commander.Commands.Keys)
{
m_console.Commands.AddCommand(topic, topic+" "+command,
topic+" "+commander.Commands[command].ShortHelp(),
String.Empty, HandleCommanderCommand);
}
}
}
private void HandleCommanderCommand(string module, string[] cmd)
{
m_sceneManager.SendCommandToPluginModules(cmd);
}
private void HandleCommanderHelp(string module, string[] cmd)
{
ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1]);
if (moduleCommander != null)
m_console.Notice(moduleCommander.Help);
}
/// <summary>