Extend scripts show command to accept a single item UUID parameter to display one script's status

Usage is now scripts show [<script-item-uuid>]
0.7.2-post-fixes
Justin Clark-Casey (justincc) 2012-01-14 00:44:19 +00:00
parent ab4c4a362f
commit 16d5ce16b6
1 changed files with 47 additions and 40 deletions

View File

@ -273,11 +273,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
MainConsole.Instance.Commands.AddCommand(
"scripts", false, "scripts show", "scripts show", "Show script information",
"Show information on all scripts known to the script engine", HandleShowScripts);
"scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information",
"Show information on all scripts known to the script engine."
+ "If a <script-item-uuid> is given then only information on that script will be shown.",
HandleShowScripts);
MainConsole.Instance.Commands.AddCommand(
"scripts", false, "show scripts", "show scripts", "Show script information",
"scripts", false, "show scripts", "show scripts [<script-item-uuid>]", "Show script information",
"Synonym for scripts show command", HandleShowScripts);
MainConsole.Instance.Commands.AddCommand(
@ -308,43 +310,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
}
public void HandleShowScripts(string module, string[] cmdparams)
{
lock (m_Scripts)
{
MainConsole.Instance.OutputFormat(
"Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName);
foreach (IScriptInstance instance in m_Scripts.Values)
{
SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
string status;
if (instance.ShuttingDown)
{
status = "shutting down";
}
else if (instance.Suspended)
{
status = "suspended";
}
else if (!instance.Running)
{
status = "stopped";
}
else
{
status = "running";
}
MainConsole.Instance.OutputFormat(
"{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})",
instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID,
sop.AbsolutePosition, status);
}
}
}
/// <summary>
/// Parse the raw item id into a script instance from the command params if it's present.
/// </summary>
@ -394,6 +359,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
public void HandleShowScripts(string module, string[] cmdparams)
{
if (cmdparams.Length == 2)
{
lock (m_Scripts)
{
MainConsole.Instance.OutputFormat(
"Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName);
}
}
HandleScriptsAction(cmdparams, HandleShowScript);
}
private void HandleShowScript(IScriptInstance instance)
{
SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
string status;
if (instance.ShuttingDown)
{
status = "shutting down";
}
else if (instance.Suspended)
{
status = "suspended";
}
else if (!instance.Running)
{
status = "stopped";
}
else
{
status = "running";
}
MainConsole.Instance.OutputFormat(
"{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})",
instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID,
sop.AbsolutePosition, status);
}
private void HandleSuspendScript(IScriptInstance instance)
{
if (!instance.Suspended)