Skip to content

Commit 1be4259

Browse files
committed
fix: Fixed CLI generation if Group command name same as endpoint Command name.
1 parent f3e9d74 commit 1be4259

File tree

118 files changed

+443
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+443
-443
lines changed

src/libs/AutoSDK.CLI/Commands/GenerateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private async Task HandleAsync(ParseResult parseResult)
198198
}).Concat(data.Methods.GroupBy(x => x.Tag)
199199
.SelectMany(x => new []
200200
{
201-
Sources.TagCommand(x.Key, x.ToImmutableArray()),
201+
Sources.GroupCommand(x.Key, x.ToImmutableArray()),
202202
}))
203203
.Concat([Sources.MainCommand(data.Tags)])
204204
.Concat([Sources.AddCommands(data.Methods, data.Tags)])

src/libs/AutoSDK.SourceGenerators/CliGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3232

3333
data
3434
.SelectMany(static (x, _) => x.Methods.GroupBy(x => x.Tag))
35-
.SelectAndReportExceptions((x, c) => Sources.TagCommand(x.Key, x.ToImmutableArray(), c)
35+
.SelectAndReportExceptions((x, c) => Sources.GroupCommand(x.Key, x.ToImmutableArray(), c)
3636
.AsFileWithName(), context, Id)
3737
.AddSource(context);
3838
data

src/libs/AutoSDK/Sources/Sources.CLI.AddCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal static class ServiceCollectionExtensions
3939
{type}>(services);").Inject()}
4040
4141
// Register grouped command services as singletons
42-
{tags.Select(x => $"{x.SingularizedName}Command").Distinct().Select((type, i) => @$"
42+
{tags.Select(x => $"{x.SingularizedName}GroupCommand").Distinct().Select((type, i) => @$"
4343
global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton<
4444
{type}>(services);").Inject()}
4545

src/libs/AutoSDK/Sources/Sources.CLI.TagCommand.cs renamed to src/libs/AutoSDK/Sources/Sources.CLI.GroupCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace AutoSDK.Generation;
77

88
public static partial class Sources
99
{
10-
public static string GenerateTagCommand(
10+
public static string GenerateGroupCommand(
1111
Tag tag,
1212
EquatableArray<EndPoint> values,
1313
CancellationToken cancellationToken = default)
@@ -22,9 +22,9 @@ public static string GenerateTagCommand(
2222
2323
namespace {values[0].Settings.Namespace}
2424
{{
25-
internal sealed partial class {tag.SingularizedName}Command : global::System.CommandLine.Command
25+
internal sealed partial class {tag.SingularizedName}GroupCommand : global::System.CommandLine.Command
2626
{{
27-
public {tag.SingularizedName}Command(
27+
public {tag.SingularizedName}GroupCommand(
2828
{values.Select(x => $"{x.NotAsyncMethodName}Command").Distinct().Select((type, i) => @$"
2929
{type} command{i},").Inject().TrimEnd(',')})
3030
: base(

src/libs/AutoSDK/Sources/Sources.CLI.MainCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ namespace {values[0].GlobalSettings.Namespace}
2222
internal sealed class MainCommand : global::System.CommandLine.RootCommand
2323
{{
2424
public MainCommand(
25-
{values.Select(x => $"{x.SingularizedName}Command").Distinct().Select((type, i) => @$"
25+
{values.Select(x => $"{x.SingularizedName}GroupCommand").Distinct().Select((type, i) => @$"
2626
{type} command{i},").Inject().TrimEnd(',')})
2727
: base(
2828
description: ""CLI tool"")
2929
{{
30-
{values.Select(x => $"{x.SingularizedName}Command").Distinct().Select((type, i) => @$"
30+
{values.Select(x => $"{x.SingularizedName}GroupCommand").Distinct().Select((type, i) => @$"
3131
Subcommands.Add(command{i});").Inject()}
3232
}}
3333
}}

src/libs/AutoSDK/Sources/Sources.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static FileWithName Command(
5656
Text: GenerateCommand(endPoint, cancellationToken: cancellationToken));
5757
}
5858

59-
public static FileWithName TagCommand(
59+
public static FileWithName GroupCommand(
6060
Tag tag,
6161
EquatableArray<EndPoint> methods,
6262
CancellationToken cancellationToken = default)
@@ -67,8 +67,8 @@ public static FileWithName TagCommand(
6767
}
6868

6969
return new FileWithName(
70-
Name: $"{methods[0].GlobalSettings.Namespace}.Commands.{tag.SingularizedName}Command.g.cs",
71-
Text: GenerateTagCommand(tag, methods, cancellationToken: cancellationToken));
70+
Name: $"{methods[0].GlobalSettings.Namespace}.Commands.{tag.SingularizedName}GroupCommand.g.cs",
71+
Text: GenerateGroupCommand(tag, methods, cancellationToken: cancellationToken));
7272
}
7373

7474
public static FileWithName MainCommand(

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.Command.g.verified.cs renamed to src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.GroupCommand.g.verified.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//HintName: G.Commands.Command.g.cs
1+
//HintName: G.Commands.GroupCommand.g.cs
22

33
#nullable enable
44

55
namespace G
66
{
7-
internal sealed partial class Command : global::System.CommandLine.Command
7+
internal sealed partial class GroupCommand : global::System.CommandLine.Command
88
{
9-
public Command(
9+
public GroupCommand(
1010
ModelsListCommand command0,
1111
ModelsGetCommand command1,
1212
BetaModelsListCommand command2,

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.MainCommand.g.verified.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace G
77
internal sealed class MainCommand : global::System.CommandLine.RootCommand
88
{
99
public MainCommand(
10-
MessageCommand command0,
11-
TextCompletionCommand command1,
12-
MessageBatcheCommand command2)
10+
MessageGroupCommand command0,
11+
TextCompletionGroupCommand command1,
12+
MessageBatcheGroupCommand command2)
1313
: base(
1414
description: "CLI tool")
1515
{

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.MessageBatcheCommand.g.verified.cs renamed to src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.MessageBatcheGroupCommand.g.verified.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//HintName: G.Commands.MessageBatcheCommand.g.cs
1+
//HintName: G.Commands.MessageBatcheGroupCommand.g.cs
22

33
#nullable enable
44

55
namespace G
66
{
7-
internal sealed partial class MessageBatcheCommand : global::System.CommandLine.Command
7+
internal sealed partial class MessageBatcheGroupCommand : global::System.CommandLine.Command
88
{
9-
public MessageBatcheCommand(
9+
public MessageBatcheGroupCommand(
1010
MessageBatchesPostCommand command0,
1111
MessageBatchesListCommand command1,
1212
MessageBatchesRetrieveCommand command2,

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.MessageCommand.g.verified.cs renamed to src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.MessageGroupCommand.g.verified.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//HintName: G.Commands.MessageCommand.g.cs
1+
//HintName: G.Commands.MessageGroupCommand.g.cs
22

33
#nullable enable
44

55
namespace G
66
{
7-
internal sealed partial class MessageCommand : global::System.CommandLine.Command
7+
internal sealed partial class MessageGroupCommand : global::System.CommandLine.Command
88
{
9-
public MessageCommand(
9+
public MessageGroupCommand(
1010
MessagesPostCommand command0,
1111
MessagesCountTokensPostCommand command1,
1212
BetaMessagesPostCommand command2,

0 commit comments

Comments
 (0)