Mantis#1580. Thank you kindly, Dmiles for a patch that:
solves an incorectly spliting and rejoining the passed in string[] cmdArgs and losing the double quoted separation of command arguments.0.6.0-stable
parent
908d91be78
commit
5b159e957a
|
@ -190,7 +190,7 @@ namespace OpenSim
|
||||||
public override void RunCmd(string command, string[] cmdparams)
|
public override void RunCmd(string command, string[] cmdparams)
|
||||||
{
|
{
|
||||||
base.RunCmd(command, cmdparams);
|
base.RunCmd(command, cmdparams);
|
||||||
RunPluginCommands(command + " " + CombineParams(cmdparams, 0));
|
RunPluginCommands(command , cmdparams);
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
case "clear-assets":
|
case "clear-assets":
|
||||||
|
@ -691,10 +691,11 @@ namespace OpenSim
|
||||||
///
|
///
|
||||||
/// returns true if a match was found, false otherwise.
|
/// returns true if a match was found, false otherwise.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RunPluginCommands(string cmdWithParams)
|
public bool RunPluginCommands(string cmd, string[] withParams)
|
||||||
{
|
{
|
||||||
ConsolePluginCommand bestMatch = null;
|
ConsolePluginCommand bestMatch = null;
|
||||||
int bestLength = 0;
|
int bestLength = 0;
|
||||||
|
String cmdWithParams = cmd + " " + String.Join(" ",withParams);
|
||||||
foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos)
|
foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos)
|
||||||
{
|
{
|
||||||
int matchLen = cmdinfo.matchLength(cmdWithParams);
|
int matchLen = cmdinfo.matchLength(cmdWithParams);
|
||||||
|
@ -705,7 +706,7 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bestMatch == null) return false;
|
if (bestMatch == null) return false;
|
||||||
bestMatch.Run(cmdWithParams.Substring(bestLength));
|
bestMatch.Run(cmd,withParams);//.Substring(bestLength));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,7 +760,7 @@ namespace OpenSim
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// command in the form of "showme new commands"
|
/// command in the form of "showme new commands"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private string m_cmdText;
|
private string[] m_cmdText;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a new ConsolePluginCommand
|
/// Construct a new ConsolePluginCommand
|
||||||
|
@ -772,7 +773,7 @@ namespace OpenSim
|
||||||
/// <param name="help">the text displayed in "help showme new commands"</param>
|
/// <param name="help">the text displayed in "help showme new commands"</param>
|
||||||
public ConsolePluginCommand(string command, ConsoleCommand dlg, string help)
|
public ConsolePluginCommand(string command, ConsoleCommand dlg, string help)
|
||||||
{
|
{
|
||||||
m_cmdText = command;
|
m_cmdText = command.Split(new char[] { ' ' });
|
||||||
m_commandDelegate = dlg;
|
m_commandDelegate = dlg;
|
||||||
m_helpText = help;
|
m_helpText = help;
|
||||||
}
|
}
|
||||||
|
@ -790,7 +791,7 @@ namespace OpenSim
|
||||||
{
|
{
|
||||||
// QUESTION: have a case insensitive flag?
|
// QUESTION: have a case insensitive flag?
|
||||||
cmdWithParams = cmdWithParams.ToLower().Trim();
|
cmdWithParams = cmdWithParams.ToLower().Trim();
|
||||||
string matchText = m_cmdText.ToLower().Trim();
|
string matchText = String.Join(" ",m_cmdText).ToLower().Trim();
|
||||||
if (cmdWithParams.StartsWith(matchText))
|
if (cmdWithParams.StartsWith(matchText))
|
||||||
{
|
{
|
||||||
// QUESTION Instead return cmdText.Length; ?
|
// QUESTION Instead return cmdText.Length; ?
|
||||||
|
@ -800,17 +801,33 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Run the delegate the incomming string may contain the command, if so, it is chopped off
|
/// Run the delegate the incomming string may contain the command, if so, it is chopped off the cmdParams[]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Run(string cmdParams)
|
public void Run(string cmd, string[] cmdParams)
|
||||||
{
|
{
|
||||||
string targetText = m_cmdText.ToLower();
|
int skipParams = 0;
|
||||||
string matchText = cmdParams.ToLower();
|
if (m_cmdText.Length > 1)
|
||||||
if (targetText.StartsWith(matchText))
|
|
||||||
{
|
{
|
||||||
cmdParams = cmdParams.Substring(matchText.Length);
|
int currentParam = 1;
|
||||||
|
while (currentParam < m_cmdText.Length)
|
||||||
|
{
|
||||||
|
if (cmdParams[skipParams].ToLower().Equals(m_cmdText[currentParam].ToLower()))
|
||||||
|
{
|
||||||
|
skipParams++;
|
||||||
}
|
}
|
||||||
m_commandDelegate(cmdParams.Trim().Split(new char[] { ' ' }));
|
currentParam++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
string[] sendCmdParams = cmdParams;
|
||||||
|
if (skipParams > 0)
|
||||||
|
{
|
||||||
|
sendCmdParams = new string[cmdParams.Length-skipParams];
|
||||||
|
for (int i=0;i<sendCmdParams.Length;i++) {
|
||||||
|
sendCmdParams[i] = cmdParams[skipParams++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_commandDelegate(sendCmdParams);//.Trim().Split(new char[] { ' ' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -818,7 +835,7 @@ namespace OpenSim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ShowHelp(ConsoleBase console)
|
public void ShowHelp(ConsoleBase console)
|
||||||
{
|
{
|
||||||
console.Notice(m_cmdText + " - " + m_helpText);
|
console.Notice(String.Join(" ", m_cmdText) + " - " + m_helpText);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -827,7 +844,7 @@ namespace OpenSim
|
||||||
public bool IsHelpfull(string cmdWithParams)
|
public bool IsHelpfull(string cmdWithParams)
|
||||||
{
|
{
|
||||||
cmdWithParams = cmdWithParams.ToLower();
|
cmdWithParams = cmdWithParams.ToLower();
|
||||||
return cmdWithParams.Contains(m_cmdText.ToLower()) || m_helpText.ToLower().Contains(cmdWithParams);
|
return cmdWithParams.Contains(String.Join(" ", m_cmdText).ToLower()) || m_helpText.ToLower().Contains(cmdWithParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue