Skip to content

Commit

Permalink
处理 #587 ; 处理用户按下Ctrl+C事件
Browse files Browse the repository at this point in the history
nilaoda committed May 26, 2023
1 parent 576a81a commit 791ece9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions BBDown/Program.cs
Original file line number Diff line number Diff line change
@@ -41,9 +41,23 @@ private static int Compare(Audio r1, Audio r2)
[JsonSerializable(typeof(MyOption))]
partial class MyOptionJsonContext : JsonSerializerContext { }

private static void Console_CancelKeyPress(object? sender, ConsoleCancelEventArgs e)
{
LogWarn("Force Exit...");
try
{
Console.ResetColor();
Console.CursorVisible = true;
if (!OperatingSystem.IsWindows())
System.Diagnostics.Process.Start("stty", "echo");
}
catch { }
Environment.Exit(0);
}

public static async Task<int> Main(params string[] args)
{
Console.CancelKeyPress += Console_CancelKeyPress;
ServicePointManager.DefaultConnectionLimit = 2048;

var rootCommand = CommandLineInvoker.GetRootCommand(DoWorkAsync);
@@ -211,6 +225,8 @@ private static async Task DoWorkAsync(MyOption myOption)
Config.COOKIE = myOption.Cookie;
Config.TOKEN = myOption.AccessToken.Replace("access_token=", "");

if (interactMode) hideStreams = false; //手动选择时不能隐藏流

if (!string.IsNullOrEmpty(myOption.WorkDir))
{
//解释环境变量

0 comments on commit 791ece9

Please sign in to comment.