Skip to content

Commit 5d8ef7f

Browse files
committed
Clean up code
1 parent 6c1e502 commit 5d8ef7f

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ namespace Microsoft.OpenApi.Hidi
1616
static class Program
1717
{
1818
static async Task Main(string[] args)
19-
{
20-
// subscribe to CancelKeyPress event to listen for termination requests from users through Ctrl+C or Ctrl+Break keys
21-
Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPressEvent);
22-
23-
var rootCommand = new RootCommand() {
24-
};
19+
{
20+
var rootCommand = new RootCommand() {};
2521

2622
// command option parameters and aliases
2723
var descriptionOption = new Option<string>("--openapi", "Input OpenAPI description file path or URL");
@@ -121,36 +117,12 @@ static async Task Main(string[] args)
121117

122118
rootCommand.Add(transformCommand);
123119
rootCommand.Add(validateCommand);
124-
120+
125121
// Parse the incoming args and invoke the handler
126122
await rootCommand.InvokeAsync(args);
127123

128124
//// Wait for logger to write messages to the console before exiting
129125
await Task.Delay(10);
130-
}
131-
132-
/// <summary>
133-
/// This event is raised when the user presses either of the two breaking key combinations: Ctrl+C or Ctrl+Break keys.
134-
/// </summary>
135-
/// <param name="sender"></param>
136-
/// <param name="eventArgs"></param>
137-
private static void Console_CancelKeyPressEvent(object sender, ConsoleCancelEventArgs eventArgs)
138-
{
139-
if ((eventArgs.SpecialKey == ConsoleSpecialKey.ControlC) || (eventArgs.SpecialKey == ConsoleSpecialKey.ControlBreak))
140-
{
141-
Console.WriteLine("CTRL+C pressed, aborting current process...");
142-
Thread.Sleep(5000);
143-
144-
if (Process.GetCurrentProcess().HasExited)
145-
{
146-
Console.WriteLine("Process has already exited.");
147-
}
148-
else
149-
{
150-
Console.WriteLine("Process has not exited, attempting to kill process...");
151-
Process.GetCurrentProcess().Kill();
152-
}
153-
}
154126
}
155127
}
156128
}

0 commit comments

Comments
 (0)