Skip to content

Commit 14dfecc

Browse files
committed
all test pass
1 parent cae78b9 commit 14dfecc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ConsoleAppFramework/Emitter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,9 @@ void EmitLeafCommand(CommandWithId? command)
634634
}
635635
else
636636
{
637-
var invokeCode = $"RunWithFilterAsync(\"{command.Command.Name}\", args, {depth}, args.AsSpan().IndexOf(\"--\"), new Command{command.Id}Invoker(this, {commandArgs.TrimStart(',', ' ')}).BuildFilter(), cancellationToken)";
637+
var invokerArgument = commandArgs.TrimStart(',', ' ');
638+
invokerArgument = (invokerArgument != "") ? $"this, {invokerArgument}" : "this";
639+
var invokeCode = $"RunWithFilterAsync(\"{command.Command.Name}\", args, {depth}, args.AsSpan().IndexOf(\"--\"), new Command{command.Id}Invoker({invokerArgument}).BuildFilter(), cancellationToken)";
638640
if (!isRunAsync)
639641
{
640642
sb.AppendLine($"{invokeCode}.GetAwaiter().GetResult();");
@@ -653,8 +655,9 @@ void EmitFilterInvoker(CommandWithId command)
653655
var commandType = command.Command.BuildDelegateSignature(command.BuildCustomDelegateTypeName(), out _);
654656
var needsCommand = commandType != null;
655657
if (needsCommand) commandType = $"{commandType} command";
658+
if (!string.IsNullOrEmpty(commandType)) commandType = ", " + commandType;
656659

657-
using (sb.BeginBlock($"sealed class Command{command.Id}Invoker(ConsoleAppBuilder builder, {commandType}) : ConsoleAppFilter(null!)"))
660+
using (sb.BeginBlock($"sealed class Command{command.Id}Invoker(ConsoleAppBuilder builder{commandType}) : ConsoleAppFilter(null!)"))
658661
{
659662
using (sb.BeginBlock($"public ConsoleAppFilter BuildFilter()"))
660663
{

0 commit comments

Comments
 (0)