aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-10-24 04:10:22 +0100
committerJustin Clark-Casey (justincc)2012-10-24 04:10:22 +0100
commit81aeecc90723658187668baa49bd168b7b333afb (patch)
tree11e62ae375450e7d8d500565e29d05cc9b0b4ec7 /OpenSim/Framework
parentGet "save oar" and "save iar" to tell you in a more friendly manner if the fi... (diff)
downloadopensim-SC-81aeecc90723658187668baa49bd168b7b333afb.zip
opensim-SC-81aeecc90723658187668baa49bd168b7b333afb.tar.gz
opensim-SC-81aeecc90723658187668baa49bd168b7b333afb.tar.bz2
opensim-SC-81aeecc90723658187668baa49bd168b7b333afb.tar.xz
Allow "show object", "show part", "dump object" and "delete object" to accept a local ID as well as a UUID.
This means that the sub-commands are now id rather than uuid, e.g. show object id
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Console/ConsoleUtil.cs58
1 files changed, 56 insertions, 2 deletions
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 3ebfdf8..16a63e0 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -38,6 +38,8 @@ namespace OpenSim.Framework.Console
38 public class ConsoleUtil 38 public class ConsoleUtil
39 { 39 {
40 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 public const int LocalIdNotFound = 0;
41 43
42 /// <summary> 44 /// <summary>
43 /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section 45 /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
@@ -87,19 +89,71 @@ namespace OpenSim.Framework.Console
87 /// Will complain to the console if parsing fails. 89 /// Will complain to the console if parsing fails.
88 /// </remarks> 90 /// </remarks>
89 /// <returns></returns> 91 /// <returns></returns>
90 /// <param name='console'></param> 92 /// <param name='console'>If null then no complaint is printed.</param>
91 /// <param name='rawUuid'></param> 93 /// <param name='rawUuid'></param>
92 /// <param name='uuid'></param> 94 /// <param name='uuid'></param>
93 public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) 95 public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
94 { 96 {
95 if (!UUID.TryParse(rawUuid, out uuid)) 97 if (!UUID.TryParse(rawUuid, out uuid))
96 { 98 {
97 console.OutputFormat("{0} is not a valid uuid", rawUuid); 99 if (console != null)
100 console.OutputFormat("{0} is not a valid uuid", rawUuid);
101
98 return false; 102 return false;
99 } 103 }
100 104
101 return true; 105 return true;
102 } 106 }
107
108 public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId)
109 {
110 if (!uint.TryParse(rawLocalId, out localId))
111 {
112 if (console != null)
113 console.OutputFormat("{0} is not a valid local id", localId);
114
115 return false;
116 }
117
118 if (localId == 0)
119 {
120 if (console != null)
121 console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId);
122
123 return false;
124 }
125
126 return true;
127 }
128
129 /// <summary>
130 /// Tries to parse the input as either a UUID or a local ID.
131 /// </summary>
132 /// <returns>true if parsing succeeded, false otherwise.</returns>
133 /// <param name='console'></param>
134 /// <param name='rawId'></param>
135 /// <param name='uuid'></param>
136 /// <param name='localId'>
137 /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded.
138 /// </param>
139 public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId)
140 {
141 if (TryParseConsoleUuid(null, rawId, out uuid))
142 {
143 localId = LocalIdNotFound;
144 return true;
145 }
146
147 if (TryParseConsoleLocalId(null, rawId, out localId))
148 {
149 return true;
150 }
151
152 if (console != null)
153 console.OutputFormat("{0} is not a valid UUID or local id", rawId);
154
155 return false;
156 }
103 157
104 /// <summary> 158 /// <summary>
105 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 159 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3