From 4455140f3040d6d2a14057e963619aa461b51c50 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 10 Feb 2012 23:52:06 +0000 Subject: Change parser to leave embedded quotes alone if the pattern is recognized as an OptionSet long option --- OpenSim/Framework/Console/CommandConsole.cs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'OpenSim/Framework/Console/CommandConsole.cs') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index a0d3541..0d6288b 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using log4net; using OpenSim.Framework; @@ -531,6 +532,11 @@ namespace OpenSim.Framework.Console public class Parser { + // If an unquoted portion ends with an element matching this regex + // and the next element contains a space, then we have stripped + // embedded quotes that should not have been stripped + private static Regex optionRegex = new Regex("^--[a-zA-Z0-9-]+=$"); + public static string[] Parse(string text) { List result = new List(); @@ -544,10 +550,38 @@ namespace OpenSim.Framework.Console if (index % 2 == 0) { string[] words = unquoted[index].Split(new char[] {' '}); + + bool option = false; foreach (string w in words) { if (w != String.Empty) + { + if (optionRegex.Match(w) == Match.Empty) + option = false; + else + option = true; result.Add(w); + } + } + // The last item matched the regex, put the quotes back + if (option) + { + // If the line ended with it, don't do anything + if (index < (unquoted.Length - 1)) + { + // Get and remove the option name + string optionText = result[result.Count - 1]; + result.RemoveAt(result.Count - 1); + + // Add the quoted value back + optionText += "\"" + unquoted[index + 1] + "\""; + + // Push the result into our return array + result.Add(optionText); + + // Skip the already used value + index++; + } } } else -- cgit v1.1 From 195b69d1ea90a123ce1a61536dffa33276c1e76a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:54:47 +0200 Subject: Allow the use of the region debug console found in recent viewers. This console will be available to estate owners and managers. If the user using the console had god privs, they can use "set console on" and "set console off" to switch on the actual region console. This allows console access from within the viewer. The region debug console can coexist with any other main console. --- OpenSim/Framework/Console/CommandConsole.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Framework/Console/CommandConsole.cs') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 87bdacd..bd23d1c 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -678,6 +678,8 @@ namespace OpenSim.Framework.Console { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event OnOutputDelegate OnOutput; + public ICommands Commands { get; private set; } public CommandConsole(string defaultPrompt) : base(defaultPrompt) @@ -697,6 +699,13 @@ namespace OpenSim.Framework.Console Output(s); } + protected void FireOnOutput(string text) + { + OnOutputDelegate onOutput = OnOutput; + if (onOutput != null) + onOutput(text); + } + /// /// Display a command prompt on the console and wait for user input /// -- cgit v1.1 From 2e7b72d3dad42288237f85d02a9769ce31109309 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 02:04:24 +0000 Subject: Revert help to display a full command list. Leave the help categories in as "help categories" in case it turns out useful in the future. May not work. --- OpenSim/Framework/Console/CommandConsole.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Console/CommandConsole.cs') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index de30414..f160404 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Console = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; public const string ItemHelpText -= @"For more information, type 'help all' to get a list of all commands, += @"For more information, type 'help' to get a list of all commands, or type help ' where is one of the following:"; /// @@ -113,15 +113,16 @@ namespace OpenSim.Framework.Console // General help if (helpParts.Count == 0) { + help.Add(GeneralHelpText); + help.AddRange(CollectAllCommandsHelp()); + } + else if (helpParts.Count == 1 && helpParts[0] == "categories") + { help.Add(""); // Will become a newline. help.Add(GeneralHelpText); help.Add(ItemHelpText); help.AddRange(CollectModulesHelp(tree)); } - else if (helpParts.Count == 1 && helpParts[0] == "all") - { - help.AddRange(CollectAllCommandsHelp()); - } else { help.AddRange(CollectHelp(helpParts)); -- cgit v1.1 From c96729b55dbb9d0025700c84b03aae35b9f42780 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 02:06:05 +0000 Subject: Add a newline before the constant help text --- OpenSim/Framework/Console/CommandConsole.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Console/CommandConsole.cs') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index f160404..106b406 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -113,6 +113,7 @@ namespace OpenSim.Framework.Console // General help if (helpParts.Count == 0) { + help.Add(""); // Will become a newline. help.Add(GeneralHelpText); help.AddRange(CollectAllCommandsHelp()); } -- cgit v1.1 From 658109700125f74b72dc1d1990e5713f06ee538e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 03:20:15 +0100 Subject: Fix new command console code to match the output of the original while keeping the new features --- OpenSim/Framework/Console/CommandConsole.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console/CommandConsole.cs') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 106b406..d703d78 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -144,8 +144,11 @@ namespace OpenSim.Framework.Console { foreach (List commands in m_modulesCommands.Values) { - var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); - help.AddRange(ourHelpText); + foreach (CommandInfo c in commands) + { + if (c.long_help != String.Empty) + help.Add(string.Format("{0} - {1}", c.help_text, c.long_help)); + } } } -- cgit v1.1