Skip to content

Commit 4d1107d

Browse files
committed
Add sentry to cli
1 parent db8df06 commit 4d1107d

File tree

5 files changed

+54
-28
lines changed

5 files changed

+54
-28
lines changed

MaiChartManager.CLI/Commands/MakeAcbCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, Settings se
6767
}
6868
catch (Exception ex)
6969
{
70+
SentrySdk.CaptureException(ex);
7071
AnsiConsole.MarkupLine($"[red]✗ 错误: {ex.Message}[/]");
7172
return 1;
7273
}
@@ -139,6 +140,7 @@ await Task.Run(() =>
139140
}
140141
catch (Exception ex)
141142
{
143+
SentrySdk.CaptureException(ex);
142144
errorCount++;
143145
task.Description = $"[red]{Path.GetFileName(source)} - 失败[/]";
144146
task.StopTask();

MaiChartManager.CLI/Commands/MakeUsmCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ await AnsiConsole.Status()
8484
}
8585
catch (Exception ex)
8686
{
87+
SentrySdk.CaptureException(ex);
8788
AnsiConsole.MarkupLine($"[red]✗ 错误: {ex.Message}[/]");
8889
return 1;
8990
}
@@ -168,6 +169,7 @@ await VideoConvert.ConvertVideoToUsm(
168169
}
169170
catch (Exception ex)
170171
{
172+
SentrySdk.CaptureException(ex);
171173
errorCount++;
172174
task.Description = $"[red]{Path.GetFileName(source)} - 失败[/]";
173175
task.Value = 100;

MaiChartManager.CLI/MaiChartManager.CLI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
<ItemGroup>
2424
<PackageReference Include="Spectre.Console.Cli" Version="0.53.0"/>
25+
<PackageReference Include="Sentry" Version="5.14.1"/>
2526
</ItemGroup>
2627

2728
</Project>

MaiChartManager.CLI/Program.cs

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,53 @@
77
Console.OutputEncoding = Encoding.UTF8;
88
Console.CancelKeyPress += (_, _) => TerminalProgress.Clear();
99

10-
AppMain.InitConfiguration(true);
11-
await IapManager.Init();
12-
13-
if (IapManager.License != IapManager.LicenseStatus.Active)
10+
try
1411
{
15-
Console.WriteLine("命令行工具目前为赞助版功能,请先使用桌面版应用程序解锁");
16-
return 1;
12+
SentrySdk.Init(o =>
13+
{
14+
// Tells which project in Sentry to send events to:
15+
o.Dsn = "https://[email protected]/3";
16+
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
17+
// We recommend adjusting this value in production.
18+
o.TracesSampleRate = 0.5;
19+
#if DEBUG
20+
o.Environment = "development";
21+
#endif
22+
});
23+
24+
AppMain.InitConfiguration(true);
25+
await IapManager.Init();
26+
27+
if (IapManager.License != IapManager.LicenseStatus.Active)
28+
{
29+
Console.WriteLine("命令行工具目前为赞助版功能,请先使用桌面版应用程序解锁");
30+
return 1;
31+
}
32+
33+
var app = new CommandApp();
34+
35+
app.Configure(config =>
36+
{
37+
config.SetApplicationName("mcm");
38+
39+
config.AddCommand<MakeUsmCommand>("makeusm")
40+
.WithDescription("将视频文件转换为 USM 格式")
41+
.WithExample("makeusm", "video.mp4")
42+
.WithExample("makeusm", "video.mp4", "-O", "output.dat")
43+
.WithExample("makeusm", "video1.mp4", "video2.mp4", "video3.mp4");
44+
45+
config.AddCommand<MakeAcbCommand>("makeacb")
46+
.WithDescription("将音频文件转换为 ACB 格式")
47+
.WithExample("makeacb", "audio.wav")
48+
.WithExample("makeacb", "audio.mp3", "-O", "output.acb")
49+
.WithExample("makeacb", "audio1.wav", "audio2.mp3", "--padding", "0.5");
50+
});
51+
52+
return await app.RunAsync(args);
1753
}
18-
19-
var app = new CommandApp();
20-
21-
app.Configure(config =>
54+
catch (Exception e)
2255
{
23-
config.SetApplicationName("mcm");
24-
25-
config.AddCommand<MakeUsmCommand>("makeusm")
26-
.WithDescription("将视频文件转换为 USM 格式")
27-
.WithExample("makeusm", "video.mp4")
28-
.WithExample("makeusm", "video.mp4", "-O", "output.dat")
29-
.WithExample("makeusm", "video1.mp4", "video2.mp4", "video3.mp4");
30-
31-
config.AddCommand<MakeAcbCommand>("makeacb")
32-
.WithDescription("将音频文件转换为 ACB 格式")
33-
.WithExample("makeacb", "audio.wav")
34-
.WithExample("makeacb", "audio.mp3", "-O", "output.acb")
35-
.WithExample("makeacb", "audio1.wav", "audio2.mp3", "--padding", "0.5");
36-
});
37-
38-
return await app.RunAsync(args);
56+
SentrySdk.CaptureException(e);
57+
Console.Error.WriteLine($"发生错误: {e.Message}");
58+
return 1;
59+
}

Packaging/Base/AppxManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
DisplayName="MaiChartManager CLI"
5757
Description="MaiChartManager Command line tool"
5858
BackgroundColor="transparent"
59-
Square150x150Logo="Square150x150Logo.png"
60-
Square44x44Logo="Square44x44Logo.png">
59+
Square150x150Logo="CLI_Square150x150Logo.png"
60+
Square44x44Logo="CLI_Square44x44Logo.png">
6161
</uap:VisualElements>
6262

6363
<Extensions>

0 commit comments

Comments
 (0)