|
|
@@ -24,10 +24,51 @@ public class ConsoleEmulator : IConsoleEmulator
|
|
|
AnsiConsole.Console = testConsole;
|
|
|
App.Configure(c => c.Settings.Console = testConsole);
|
|
|
|
|
|
- await App.RunAsync(input.Split(" ", StringSplitOptions.RemoveEmptyEntries));
|
|
|
+ await App.RunAsync(ParseArguments(input));
|
|
|
|
|
|
return testConsole.Output;
|
|
|
}
|
|
|
+
|
|
|
+ internal static string[] ParseArguments(string input)
|
|
|
+ {
|
|
|
+ var args = new List<string>();
|
|
|
+ var current = new System.Text.StringBuilder();
|
|
|
+ char? quote = null;
|
|
|
+
|
|
|
+ for (var i = 0; i < input.Length; i++)
|
|
|
+ {
|
|
|
+ var c = input[i];
|
|
|
+
|
|
|
+ if (quote.HasValue)
|
|
|
+ {
|
|
|
+ if (c == quote.Value)
|
|
|
+ quote = null;
|
|
|
+ else
|
|
|
+ current.Append(c);
|
|
|
+ }
|
|
|
+ else if (c is '"' or '\'')
|
|
|
+ {
|
|
|
+ quote = c;
|
|
|
+ }
|
|
|
+ else if (c == ' ')
|
|
|
+ {
|
|
|
+ if (current.Length > 0)
|
|
|
+ {
|
|
|
+ args.Add(current.ToString());
|
|
|
+ current.Clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ current.Append(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (current.Length > 0)
|
|
|
+ args.Add(current.ToString());
|
|
|
+
|
|
|
+ return args.ToArray();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public sealed class TypeRegistrar : ITypeRegistrar
|