Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Cocona instead of ConsoleAppFramework #258

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AspNetCore.SignalR.OpenTelemetry" Version="1.4.0" />
<PackageVersion Include="Cocona" Version="2.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.8.0" />
Expand All @@ -23,7 +24,6 @@
<PackageVersion Include="TypedSignalR.Client.Attributes" Version="1.1.0" />
<PackageVersion Include="TypedSignalR.Client.DevTools" Version="1.2.4" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageVersion Include="ConsoleAppFramework" Version="4.2.4" />
<PackageVersion Include="MessagePack" Version="2.5.187" />
<PackageVersion Include="MessagePack.AspNetCoreMvcFormatter" Version="2.5.129" />
</ItemGroup>
Expand Down
22 changes: 11 additions & 11 deletions src/TypedSignalR.Client.TypeScript.Generator/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cocona;
using Microsoft.Build.Framework;
using Microsoft.Build.Logging;
using Microsoft.CodeAnalysis;
Expand All @@ -14,7 +15,7 @@

namespace TypedSignalR.Client.TypeScript;

public class App : ConsoleAppBase
public class App : CoconaConsoleAppBase
{
private readonly ILogger<App> _logger;

Expand All @@ -23,25 +24,24 @@ public App(ILogger<App> logger)
_logger = logger;
}

[RootCommand]
public async Task Transpile(
[Option("p", "Path to the project file (XXX.csproj)")]
[Option('p', Description = "Path to the project file (XXX.csproj)")]
string project,
[Option("o", "Output directory")]
[Option('o', Description ="Output directory")]
string output,
[Option("eol", "lf / crlf / cr")]
[Option("eol", Description ="lf / crlf / cr")]
NewLineOption newLine = NewLineOption.Lf,
[Option("asm", "Flag whether to extend the transpile target to the referenced assembly.")]
[Option("asm", Description ="Flag whether to extend the transpile target to the referenced assembly.")]
bool assemblies = false,
[Option("s", "JSON / MessagePack : The output type will be suitable for the selected serializer.")]
[Option('s', Description ="JSON / MessagePack : The output type will be suitable for the selected serializer.")]
SerializerOption serializer = SerializerOption.Json,
[Option("n", "camelCase (default) / PascalCase / none (The name in C# is used as it is.)")]
[Option('n', Description ="camelCase (default) / PascalCase / none (The name in C# is used as it is.)")]
NamingStyle namingStyle = NamingStyle.CamelCase,
[Option("en", "value (default) / name / nameCamel / NamePascal / union / unionCamel / UnionPascal")]
[Option(Description ="value (default) / name / nameCamel / NamePascal / union / unionCamel / UnionPascal")]
EnumStyle @enum = EnumStyle.Value,
[Option("m", "camelCase (default) / PascalCase / none (The name in C# is used as it is.)")]
[Option('m', Description = "camelCase (default) / PascalCase / none (The name in C# is used as it is.)")]
MethodStyle method = MethodStyle.CamelCase,
[Option("attr", "The flag whether attributes such as JsonPropertyName should affect transpilation.")]
[Option("attr", Description ="The flag whether attributes such as JsonPropertyName should affect transpilation.")]
bool attribute = true)
{
_logger.Log(LogLevel.Information, "Start loading the csproj of {path}.", Path.GetFullPath(project));
Expand Down
11 changes: 10 additions & 1 deletion src/TypedSignalR.Client.TypeScript.Generator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
using Cocona;
using Microsoft.Build.Locator;
using Microsoft.Extensions.Logging;
using TypedSignalR.Client.TypeScript;

MSBuildLocator.RegisterDefaults();

var app = ConsoleApp.Create(args);
var builder = CoconaApp.CreateBuilder();

builder.Logging.AddSimpleConsole(options =>
{
options.SingleLine = true;
});

var app = builder.Build();

app.AddCommands<App>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ConsoleAppFramework" />
<PackageReference Include="Cocona" />
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
Expand Down