Skip to content

Commit 4bbabf6

Browse files
committed
fix: Spectre.CLI commands do not exit when pressing Ctrl + C
1 parent 843a380 commit 4bbabf6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/AWS.Deploy.CLI/CommandReturnCodes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ public class CommandReturnCodes
3434
/// using a TCP port that is already in use.
3535
/// </summary>
3636
public const int TCP_PORT_ERROR = -100;
37+
/// <summary>
38+
/// A command was canceled by a user.
39+
/// </summary>
40+
public const int USER_CANCEL = 130;
3741
}
3842
}

src/AWS.Deploy.CLI/Commands/CancellableAsyncCommand.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Runtime.InteropServices;
55
using System.Threading;
66
using System.Threading.Tasks;
7+
using AWS.Deploy.CLI;
78

89
namespace Spectre.Console.Cli;
910

@@ -36,6 +37,8 @@ void onSignal(PosixSignalContext context)
3637
{
3738
context.Cancel = true;
3839
cancellationSource.Cancel();
40+
41+
Environment.Exit(CommandReturnCodes.USER_CANCEL);
3942
}
4043
}
4144
}

0 commit comments

Comments
 (0)