aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorHomer Horwitz2009-01-25 16:12:55 +0000
committerHomer Horwitz2009-01-25 16:12:55 +0000
commitb405d9226092916c22dc11ea30dd24e71354660c (patch)
treea0a37e3ae27b1d79fe6bfcb778a9c027b37d06dd /OpenSim
parentAdd an override of the ! operator to lsl integer. (diff)
downloadopensim-SC_OLD-b405d9226092916c22dc11ea30dd24e71354660c.zip
opensim-SC_OLD-b405d9226092916c22dc11ea30dd24e71354660c.tar.gz
opensim-SC_OLD-b405d9226092916c22dc11ea30dd24e71354660c.tar.bz2
opensim-SC_OLD-b405d9226092916c22dc11ea30dd24e71354660c.tar.xz
* Fixed a small logical error in error handling of console commands.
* Console command help should be output to the console, not to the log (as "help" does it already). That allows getting help/answers even if you only log into a file. Fixes Mantis#2916.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs38
1 files changed, 22 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
index 82f18a1..ae34d37 100644
--- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
41 /// </summary> 41 /// </summary>
42 public class Command : ICommand 42 public class Command : ICommand
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private List<CommandArgument> m_args = new List<CommandArgument>(); 45 private List<CommandArgument> m_args = new List<CommandArgument>();
46 46
47 private Action<object[]> m_command; 47 private Action<object[]> m_command;
@@ -94,13 +94,13 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
94 94
95 public void ShowConsoleHelp() 95 public void ShowConsoleHelp()
96 { 96 {
97 m_log.Info("== " + Name + " =="); 97 Console.WriteLine("== " + Name + " ==");
98 m_log.Info(m_help); 98 Console.WriteLine(m_help);
99 m_log.Info("= Parameters ="); 99 Console.WriteLine("= Parameters =");
100 foreach (CommandArgument arg in m_args) 100 foreach (CommandArgument arg in m_args)
101 { 101 {
102 m_log.Info("* " + arg.Name + " (" + arg.ArgumentType + ")"); 102 Console.WriteLine("* " + arg.Name + " (" + arg.ArgumentType + ")");
103 m_log.Info("\t" + arg.HelpText); 103 Console.WriteLine("\t" + arg.HelpText);
104 } 104 }
105 } 105 }
106 106
@@ -110,13 +110,13 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
110 110
111 if (args.Length < cleanArgs.Length) 111 if (args.Length < cleanArgs.Length)
112 { 112 {
113 m_log.Error("Missing " + (cleanArgs.Length - args.Length) + " argument(s)"); 113 Console.WriteLine("ERROR: Missing " + (cleanArgs.Length - args.Length) + " argument(s)");
114 ShowConsoleHelp(); 114 ShowConsoleHelp();
115 return; 115 return;
116 } 116 }
117 if (args.Length > cleanArgs.Length) 117 if (args.Length > cleanArgs.Length)
118 { 118 {
119 m_log.Error("Too many arguments for this command. Type '<module> <command> help' for help."); 119 Console.WriteLine("ERROR: Too many arguments for this command. Type '<module> <command> help' for help.");
120 return; 120 return;
121 } 121 }
122 122
@@ -125,7 +125,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
125 { 125 {
126 if (string.IsNullOrEmpty(arg.ToString())) 126 if (string.IsNullOrEmpty(arg.ToString()))
127 { 127 {
128 m_log.Error("Empty arguments are not allowed"); 128 Console.WriteLine("ERROR: Empty arguments are not allowed");
129 return; 129 return;
130 } 130 }
131 try 131 try
@@ -145,15 +145,16 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
145 m_args[i].ArgumentValue = Boolean.Parse(arg.ToString()); 145 m_args[i].ArgumentValue = Boolean.Parse(arg.ToString());
146 break; 146 break;
147 default: 147 default:
148 m_log.Error("Unknown desired type for argument " + m_args[i].Name + " on command " + m_name); 148 Console.WriteLine("ERROR: Unknown desired type for argument " + m_args[i].Name + " on command " + m_name);
149 break; 149 break;
150 } 150 }
151 } 151 }
152 catch (FormatException) 152 catch (FormatException)
153 { 153 {
154 m_log.Error("Argument number " + (i + 1) + 154 Console.WriteLine("ERROR: Argument number " + (i + 1) +
155 " (" + m_args[i].Name + ") must be a valid " + 155 " (" + m_args[i].Name + ") must be a valid " +
156 m_args[i].ArgumentType.ToLower() + "."); 156 m_args[i].ArgumentType.ToLower() + ".");
157 return;
157 } 158 }
158 cleanArgs[i] = m_args[i].ArgumentValue; 159 cleanArgs[i] = m_args[i].ArgumentValue;
159 160
@@ -289,11 +290,16 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
289 } 290 }
290 else 291 else
291 { 292 {
292 if (function != "help")
293 m_log.Error("Invalid command - No such command exists");
294 if (function == "api") 293 if (function == "api")
294 {
295 m_log.Info(GenerateRuntimeAPI()); 295 m_log.Info(GenerateRuntimeAPI());
296 ShowConsoleHelp(); 296 }
297 else
298 {
299 if (function != "help")
300 Console.WriteLine("ERROR: Invalid command - No such command exists");
301 ShowConsoleHelp();
302 }
297 } 303 }
298 } 304 }
299 305
@@ -301,10 +307,10 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
301 307
302 private void ShowConsoleHelp() 308 private void ShowConsoleHelp()
303 { 309 {
304 m_log.Info("===" + m_name + "==="); 310 Console.WriteLine("===" + m_name + "===");
305 foreach (ICommand com in m_commands.Values) 311 foreach (ICommand com in m_commands.Values)
306 { 312 {
307 m_log.Info("* " + com.Name + " - " + com.Help); 313 Console.WriteLine("* " + com.Name + " - " + com.Help);
308 } 314 }
309 } 315 }
310 316