-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
43 lines (34 loc) · 1.02 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Spectre.Console.Cli;
using Spectre.Console.Cli.Extensions.DependencyInjection;
using SQLServerPing.Commands;
try
{
var serviceCollection = new ServiceCollection()
.AddLogging(configure =>
configure
.AddSimpleConsole(opts => {
opts.TimestampFormat = "yyyy-MM-dd HH:mm:ss ";
})
);
using var registrar = new DependencyInjectionRegistrar(serviceCollection);
var app = new CommandApp(registrar);
app.Configure(
config =>
{
config.ValidateExamples();
config.Settings.ApplicationName = "SQLPing";
//config.AddCommand<PingCommand>("ping")
// .WithDescription("Ping SQL Server until stopped")
// .WithExample(new[] { "ping" });
});
app.SetDefaultCommand<PingCommand>();
return await app.RunAsync(args);
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
return 1;
}