From 1cbe4363a3976ed7cad489438159b1d3ebc3d6e7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 19 Oct 2012 00:37:25 +0100 Subject: [PATCH] Make "show part" console commands print out information about each item the part contains --- .../Objects/Commands/ObjectCommandsModule.cs | 113 ++++++++++++++---- 1 file changed, 93 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 6feba210d7..87241e1559 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -141,7 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object uuid", "show object uuid [--full] ", "Show details of a scene object with the given UUID", - "The --full option will print out information on all the parts of the object.", + "The --full option will print out information on all the parts of the object.\n" + + "For yet more detailed part information, use the \"show part\" commands.", HandleShowObjectByUuid); m_console.Commands.AddCommand( @@ -151,6 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object name [--full] [--regex] ", "Show details of scene objects with the given name.", "The --full option will print out information on all the parts of the object.\n" + + "For yet more detailed part information, use the \"show part\" commands.\n" + "If --regex is specified then the name is treatead as a regular expression.", HandleShowObjectByName); @@ -161,6 +163,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object pos [--full] to ", "Show details of scene objects within the given area.", "The --full option will print out information on all the parts of the object.\n" + + "For yet more detailed part information, use the \"show part\" commands.\n" + "Each component of the coord is comma separated. There must be no spaces between the commas.\n" + "If you don't care about the z component you can simply omit it.\n" + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" @@ -242,7 +245,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands m_console.OutputFormat(sb.ToString()); } - private void OutputSopsToConsole(Predicate searchPredicate) + private void OutputSopsToConsole(Predicate searchPredicate, bool showFull) { List sceneObjects = m_scene.GetSceneObjectGroups(); List parts = new List(); @@ -253,7 +256,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectPart part in parts) { - AddScenePartReport(sb, part); + AddScenePartReport(sb, part, showFull); sb.Append("\n"); } @@ -362,21 +365,27 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands OutputSogsToConsole(searchPredicate, showFull); } - private void HandleShowPartByUuid(string module, string[] cmd) + private void HandleShowPartByUuid(string module, string[] cmdparams) { if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) return; - if (cmd.Length < 4) +// bool showFull = false; + OptionSet options = new OptionSet(); +// options.Add("full", v => showFull = v != null ); + + List mainParams = options.Parse(cmdparams); + + if (mainParams.Count < 4) { - m_console.OutputFormat("Usage: show part uuid "); + m_console.OutputFormat("Usage: show part uuid [--full] "); return; } UUID objectUuid; - if (!UUID.TryParse(cmd[3], out objectUuid)) + if (!UUID.TryParse(mainParams[3], out objectUuid)) { - m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); + m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]); return; } @@ -389,7 +398,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands } StringBuilder sb = new StringBuilder(); - AddScenePartReport(sb, sop); + AddScenePartReport(sb, sop, true); m_console.OutputFormat(sb.ToString()); } @@ -399,13 +408,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) return; - if (cmdparams.Length < 5) +// bool showFull = false; + OptionSet options = new OptionSet(); +// options.Add("full", v => showFull = v != null ); + + List mainParams = options.Parse(cmdparams); + + if (mainParams.Count < 5) { - m_console.OutputFormat("Usage: show part pos to "); + m_console.OutputFormat("Usage: show part pos [--full] to "); return; } - string rawConsoleStartVector = cmdparams[3]; + string rawConsoleStartVector = mainParams[3]; Vector3 startVector; if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector)) @@ -414,7 +429,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands return; } - string rawConsoleEndVector = cmdparams[5]; + string rawConsoleEndVector = mainParams[5]; Vector3 endVector; if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector)) @@ -423,7 +438,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands return; } - OutputSopsToConsole(sop => Util.IsInsideBox(sop.AbsolutePosition, startVector, endVector)); + OutputSopsToConsole(sop => Util.IsInsideBox(sop.AbsolutePosition, startVector, endVector), true); } private void HandleShowPartByName(string module, string[] cmdparams) @@ -431,14 +446,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) return; +// bool showFull = false; bool useRegex = false; - OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); + OptionSet options = new OptionSet(); +// options.Add("full", v => showFull = v != null ); + options.Add("regex", v => useRegex = v != null ); List mainParams = options.Parse(cmdparams); if (mainParams.Count < 4) { - m_console.OutputFormat("Usage: show part name [--regex] "); + m_console.OutputFormat("Usage: show part name [--full] [--regex] "); return; } @@ -456,16 +474,26 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands searchPredicate = sop => sop.Name == name; } - OutputSopsToConsole(searchPredicate); + OutputSopsToConsole(searchPredicate, true); } + /// + /// Append a scene object report to an input StringBuilder + /// + /// + /// + /// + /// + /// If true then information on all parts of an object is appended. + /// If false then only summary information about an object is appended. + /// private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so, bool showFull) { if (showFull) { foreach (SceneObjectPart sop in so.Parts) { - AddScenePartReport(sb, sop); + AddScenePartReport(sb, sop, false); sb.Append("\n"); } } @@ -491,7 +519,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands return sb.Append(cdl.ToString()); } - private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop) + /// + /// Append a scene object part report to an input StringBuilder + /// + /// + /// + /// + /// + /// If true then information on each inventory item will be shown. + /// If false then only summary inventory information is shown. + /// + private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop, bool showFull) { ConsoleDisplayList cdl = new ConsoleDisplayList(); cdl.AddRow("Name", sop.Name); @@ -504,11 +542,46 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands sop.IsRoot ? "Is Root" : string.Format("{0} {1}", sop.ParentGroup.Name, sop.ParentGroup.UUID)); cdl.AddRow("Link number", sop.LinkNum); cdl.AddRow("Flags", sop.Flags); - cdl.AddRow("Items", sop.Inventory.Count); + + object itemsOutput; + if (showFull) + { + StringBuilder itemsSb = new StringBuilder("\n"); + itemsOutput = AddScenePartItemsReport(itemsSb, sop.Inventory).ToString(); + } + else + { + itemsOutput = sop.Inventory.Count; + } + + + cdl.AddRow("Items", itemsOutput); return sb.Append(cdl.ToString()); } + private StringBuilder AddScenePartItemsReport(StringBuilder sb, IEntityInventory inv) + { + ConsoleDisplayTable cdt = new ConsoleDisplayTable(); + cdt.Indent = 2; + + cdt.AddColumn("Name", 50); + cdt.AddColumn("Type", 12); + cdt.AddColumn("Running", 7); + cdt.AddColumn("Item UUID", 36); + cdt.AddColumn("Asset UUID", 36); + + foreach (TaskInventoryItem item in inv.GetInventoryItems()) + cdt.AddRow( + item.Name, + ((InventoryType)item.InvType).ToString(), + (InventoryType)item.InvType == InventoryType.LSL ? item.ScriptRunning.ToString() : "n/a", + item.ItemID.ToString(), + item.AssetID.ToString()); + + return sb.Append(cdt.ToString()); + } + private void HandleDeleteObject(string module, string[] cmd) { if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))