Add support for quoting parameters with spaces
This commit is contained in:
parent
056a581f60
commit
b2eea0abb9
1 changed files with 19 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using IllusionPlugin;
|
using IllusionPlugin;
|
||||||
|
@ -28,8 +28,23 @@ namespace TBConsole
|
||||||
if (_logHandler == null)
|
if (_logHandler == null)
|
||||||
Debug.unityLogger.logHandler = _logHandler = new UnityLogHandler(Debug.unityLogger.logHandler);
|
Debug.unityLogger.logHandler = _logHandler = new UnityLogHandler(Debug.unityLogger.logHandler);
|
||||||
var logTask = _logHandler.CollectLogMessages();
|
var logTask = _logHandler.CollectLogMessages();
|
||||||
var cmdparts = command.Split(' ');
|
bool inString = false;
|
||||||
switch (cmdparts.Length)
|
var cmdparts = new List<string>();
|
||||||
|
command = command.Trim();
|
||||||
|
int lastIndex = 0;
|
||||||
|
for (int i = 0; i <= command.Length; i++)
|
||||||
|
{
|
||||||
|
if (i < command.Length && command[i] == '"') inString = !inString;
|
||||||
|
else if (!inString && (i == command.Length || command[i] == ' '))
|
||||||
|
{
|
||||||
|
cmdparts.Add(command.Substring(lastIndex, i - lastIndex).Trim('"'));
|
||||||
|
lastIndex = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Console.WriteLine("Command parts: " + cmdparts.Aggregate((a, b) => a + ", " + b));
|
||||||
|
|
||||||
|
switch (cmdparts.Count)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
ExistingCommands.Call(cmdparts[0]);
|
ExistingCommands.Call(cmdparts[0]);
|
||||||
|
|
Loading…
Reference in a new issue