aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Console/ConsoleBase.cs129
-rw-r--r--OpenSim/Region/Application/OpenSim.cs3
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs12
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs8
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs4
5 files changed, 137 insertions, 19 deletions
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 380894d..ef9b224 100644
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -38,27 +38,111 @@ namespace OpenSim.Framework.Console
38 38
39 public class Commands 39 public class Commands
40 { 40 {
41 /// <summary>
42 /// Encapsulates a command that can be invoked from the console
43 /// </summary>
41 private class CommandInfo 44 private class CommandInfo
42 { 45 {
46 /// <value>
47 /// The module from which this command comes
48 /// </value>
43 public string module; 49 public string module;
50
51 /// <value>
52 /// Very short BNF description
53 /// </value>
44 public string help_text; 54 public string help_text;
55
56 /// <value>
57 /// Longer one line help text
58 /// </value>
45 public string long_help; 59 public string long_help;
60
61 /// <value>
62 /// Full descriptive help for this command
63 /// </value>
64 public string descriptive_help;
65
66 /// <value>
67 /// The method to invoke for this command
68 /// </value>
46 public CommandDelegate fn; 69 public CommandDelegate fn;
47 } 70 }
48 71
72 /// <value>
73 /// Commands organized by keyword in a tree
74 /// </value>
49 private Dictionary<string, Object> tree = 75 private Dictionary<string, Object> tree =
50 new Dictionary<string, Object>(); 76 new Dictionary<string, Object>();
51 77
52 public List<string> GetHelp() 78 /// <summary>
53 { 79 /// Get help for the given help string
80 /// </summary>
81 /// <param name="helpParts">Parsed parts of the help string. If empty then general help is returned.</param>
82 /// <returns></returns>
83 public List<string> GetHelp(string[] cmd)
84 {
54 List<string> help = new List<string>(); 85 List<string> help = new List<string>();
86 List<string> helpParts = new List<string>(cmd);
87
88 // Remove initial help keyword
89 helpParts.RemoveAt(0);
55 90
56 help.AddRange(CollectHelp(tree)); 91 // General help
57 92 if (helpParts.Count == 0)
58 help.Sort(); 93 {
94 help.AddRange(CollectHelp(tree));
95 help.Sort();
96 }
97 else
98 {
99 help.AddRange(CollectHelp(helpParts));
100 }
59 101
60 return help; 102 return help;
61 } 103 }
104
105 /// <summary>
106 /// See if we can find the requested command in order to display longer help
107 /// </summary>
108 /// <param name="helpParts"></param>
109 /// <returns></returns>
110 private List<string> CollectHelp(List<string> helpParts)
111 {
112 string originalHelpRequest = string.Join(" ", helpParts.ToArray());
113 List<string> help = new List<string>();
114
115 Dictionary<string, object> dict = tree;
116 while (helpParts.Count > 0)
117 {
118 string helpPart = helpParts[0];
119
120 if (!dict.ContainsKey(helpPart))
121 break;
122
123 //System.Console.WriteLine("Found {0}", helpParts[0]);
124
125 if (dict[helpPart] is Dictionary<string, Object>)
126 dict = (Dictionary<string, object>)dict[helpPart];
127
128 helpParts.RemoveAt(0);
129 }
130
131 // There was a command for the given help string
132 if (dict.ContainsKey(String.Empty))
133 {
134 CommandInfo commandInfo = (CommandInfo)dict[String.Empty];
135 help.Add(commandInfo.help_text);
136 help.Add(commandInfo.long_help);
137 help.Add(commandInfo.descriptive_help);
138 }
139 else
140 {
141 help.Add(string.Format("No help is available for {0}", originalHelpRequest));
142 }
143
144 return help;
145 }
62 146
63 private List<string> CollectHelp(Dictionary<string, Object> dict) 147 private List<string> CollectHelp(Dictionary<string, Object> dict)
64 { 148 {
@@ -79,12 +163,37 @@ namespace OpenSim.Framework.Console
79 } 163 }
80 return result; 164 return result;
81 } 165 }
166
167 /// <summary>
168 /// Add a command to those which can be invoked from the console.
169 /// </summary>
170 /// <param name="module"></param>
171 /// <param name="command"></param>
172 /// <param name="help"></param>
173 /// <param name="longhelp"></param>
174 /// <param name="fn"></param>
175 public void AddCommand(
176 string module, string command, string help, string longhelp, CommandDelegate fn)
177 {
178 AddCommand(module, command, help, longhelp, String.Empty, fn);
179 }
82 180
83 public void AddCommand(string module, string command, string help, string longhelp, CommandDelegate fn) 181 /// <summary>
182 /// Add a command to those which can be invoked from the console.
183 /// </summary>
184 /// <param name="module"></param>
185 /// <param name="command"></param>
186 /// <param name="help"></param>
187 /// <param name="longhelp"></param>
188 /// <param name="descriptivehelp"></param>
189 /// <param name="fn"></param>
190 public void AddCommand(
191 string module, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn)
84 { 192 {
85 string[] parts = Parser.Parse(command); 193 string[] parts = Parser.Parse(command);
86 194
87 Dictionary<string, Object> current = tree; 195 Dictionary<string, Object> current = tree;
196
88 foreach (string s in parts) 197 foreach (string s in parts)
89 { 198 {
90 if (current.ContainsKey(s)) 199 if (current.ContainsKey(s))
@@ -105,10 +214,12 @@ namespace OpenSim.Framework.Console
105 214
106 if (current.ContainsKey(String.Empty)) 215 if (current.ContainsKey(String.Empty))
107 return; 216 return;
217
108 CommandInfo info = new CommandInfo(); 218 CommandInfo info = new CommandInfo();
109 info.module = module; 219 info.module = module;
110 info.help_text = help; 220 info.help_text = help;
111 info.long_help = longhelp; 221 info.long_help = longhelp;
222 info.descriptive_help = descriptivehelp;
112 info.fn = fn; 223 info.fn = fn;
113 current[String.Empty] = info; 224 current[String.Empty] = info;
114 } 225 }
@@ -285,7 +396,9 @@ namespace OpenSim.Framework.Console
285 { 396 {
286 DefaultPrompt = defaultPrompt; 397 DefaultPrompt = defaultPrompt;
287 398
288 Commands.AddCommand("console", "help", "help", "Get command list", Help); 399 Commands.AddCommand(
400 "console", "help", "help [<command>]",
401 "Get general command list or more detailed help on a specific command", Help);
289 } 402 }
290 403
291 private void AddToHistory(string text) 404 private void AddToHistory(string text)
@@ -517,7 +630,7 @@ namespace OpenSim.Framework.Console
517 630
518 private void Help(string module, string[] cmd) 631 private void Help(string module, string[] cmd)
519 { 632 {
520 List<string> help = Commands.GetHelp(); 633 List<string> help = Commands.GetHelp(cmd);
521 634
522 foreach (string s in help) 635 foreach (string s in help)
523 Output(s); 636 Output(s);
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 5bce225..d706e05 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -142,7 +142,8 @@ namespace OpenSim
142 142
143 m_console.Commands.AddCommand("region", "save oar", 143 m_console.Commands.AddCommand("region", "save oar",
144 "save oar <oar name>", 144 "save oar <oar name>",
145 "Save a region's data to an OAR archive", SaveOar); 145 "Save a region's data to an OAR archive",
146 "More information on forthcoming options here soon", SaveOar);
146 147
147 m_console.Commands.AddCommand("region", "save inventory", 148 m_console.Commands.AddCommand("region", "save inventory",
148 "save inventory <first> <last> <path> <file>", 149 "save inventory <first> <last> <path> <file>",
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4d56147..d032864 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -203,14 +203,14 @@ namespace OpenSim
203 203
204 foreach (string topic in topics) 204 foreach (string topic in topics)
205 { 205 {
206 m_console.Commands.AddCommand("plugin", "help "+topic, 206 m_console.Commands.AddCommand("plugin", "help " + topic,
207 "help "+topic, 207 "help " + topic,
208 "Get help on plugin command '"+topic+"'", 208 "Get help on plugin command '" + topic + "'",
209 HandleCommanderHelp); 209 HandleCommanderHelp);
210 210
211 m_console.Commands.AddCommand("plugin", topic, 211 m_console.Commands.AddCommand("plugin", topic,
212 topic, 212 topic,
213 "Execute subcommand for plugin '"+topic+"'", 213 "Execute subcommand for plugin '" + topic + "'",
214 null); 214 null);
215 215
216 ICommander commander = 216 ICommander commander =
@@ -221,8 +221,8 @@ namespace OpenSim
221 221
222 foreach (string command in commander.Commands.Keys) 222 foreach (string command in commander.Commands.Keys)
223 { 223 {
224 m_console.Commands.AddCommand(topic, topic+" "+command, 224 m_console.Commands.AddCommand(topic, topic + " " + command,
225 topic+" "+commander.Commands[command].ShortHelp(), 225 topic + " " + commander.Commands[command].ShortHelp(),
226 String.Empty, HandleCommanderCommand); 226 String.Empty, HandleCommanderCommand);
227 } 227 }
228 } 228 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
index ed494fc..cd81169 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
@@ -64,11 +64,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
64 64
65 public void Close() 65 public void Close()
66 { 66 {
67 } 67 }
68 68
69 public void ArchiveRegion(string savePath) 69 public void ArchiveRegion(string savePath)
70 { 70 {
71 m_log.InfoFormat("[SCENE]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); 71 m_log.InfoFormat(
72 "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath);
72 73
73 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); 74 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
74 } 75 }
@@ -80,7 +81,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
80 81
81 public void DearchiveRegion(string loadPath) 82 public void DearchiveRegion(string loadPath)
82 { 83 {
83 m_log.InfoFormat("[SCENE]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 84 m_log.InfoFormat(
85 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
84 86
85 new ArchiveReadRequest(m_scene, loadPath).DearchiveRegion(); 87 new ArchiveReadRequest(m_scene, loadPath).DearchiveRegion();
86 } 88 }
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index e48ef13..8838e39 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -204,7 +204,9 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
204 204
205 m_bypassPermissions = val; 205 m_bypassPermissions = val;
206 206
207 m_log.InfoFormat("[PERMISSIONS] Set permissions bypass to {0} for {1}", m_bypassPermissions, m_scene.RegionInfo.RegionName); 207 m_log.InfoFormat(
208 "[PERMISSIONS]: Set permissions bypass to {0} for {1}",
209 m_bypassPermissions, m_scene.RegionInfo.RegionName);
208 } 210 }
209 } 211 }
210 212