Parse quoted strings correctly

When parsing quoted strings, space was not handled
properly in remaining arguments.

Fixes #186
This commit is contained in:
Patrik Svensson
2020-12-30 18:29:20 +01:00
committed by Patrik Svensson
parent 241423dd16
commit 79742ce9e3
9 changed files with 86 additions and 31 deletions

View File

@ -0,0 +1,39 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Spectre.Console.Cli;
namespace Spectre.Console.Tests.Data
{
public sealed class DumpRemainingCommand : Command<EmptyCommandSettings>
{
private readonly IAnsiConsole _console;
public DumpRemainingCommand(IAnsiConsole console)
{
_console = console;
}
public override int Execute([NotNull] CommandContext context, [NotNull] EmptyCommandSettings settings)
{
if (context.Remaining.Raw.Count > 0)
{
_console.WriteLine("# Raw");
foreach (var item in context.Remaining.Raw)
{
_console.WriteLine(item);
}
}
if (context.Remaining.Parsed.Count > 0)
{
_console.WriteLine("# Parsed");
foreach (var item in context.Remaining.Parsed)
{
_console.WriteLine(string.Format("{0}={1}", item.Key, string.Join(",", item.Select(x => x))));
}
}
return 0;
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using Spectre.Console.Cli;
namespace Spectre.Console.Tests.Data
{
public sealed class InterceptingCommand<TSettings> : Command<TSettings>
where TSettings : CommandSettings
{
private readonly Action<CommandContext, TSettings> _action;
public InterceptingCommand(Action<CommandContext, TSettings> action)
{
_action = action ?? throw new ArgumentNullException(nameof(action));
}
public override int Execute(CommandContext context, TSettings settings)
{
_action(context, settings);
return 0;
}
}
}