-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (45 loc) · 1.75 KB
/
Program.cs
File metadata and controls
49 lines (45 loc) · 1.75 KB
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
44
45
46
47
48
49
using Tomlyn;
using System;
using System.Data;
using Tomlyn.Model;
using Newtonsoft.Json;
using Microsoft.Data.SqlClient;
using System.Diagnostics;
using Spectre.Console.Cli;
using Spectre.Console;
using SqlBench;
internal class Program {
private static void Main(string[] args) {
try {
var app = new CommandApp();
app.Configure(config => {
config.PropagateExceptions();
config.AddCommand<SqlBench.Commands.BenchCommand>("bench")
.WithDescription("Run benchmarks")
.WithExample(new[] { "bench" });
config.AddCommand<SqlBench.Commands.InitCommand>("init")
.WithDescription("Initialize the current directory with configuration and bench cases sql");
});
app.Run(args);
} catch (UserCausedException ex) {
AnsiConsole.MarkupLineInterpolated($"[red]{ex.Message}[/]");
foreach (var err in ex.UserErrors) {
AnsiConsole.MarkupLineInterpolated($"[red]{err}[/]");
}
if (ex.Data?.Count > 0) {
var tree = new Tree("[gold1]Exception Data[/]");
var table = new Table()
.RoundedBorder()
.AddColumn("Key")
.AddColumn("Value");
tree.AddNode(table);
foreach (var k in ex.Data.Keys) {
table.AddRow($"[aqua]{k?.ToString()?.EscapeMarkup()}[/]", $"[yellow]{ex.Data[k]?.ToString()?.EscapeMarkup()}[/]");
}
AnsiConsole.Write(tree);
}
} catch (Exception ex) {
AnsiConsole.WriteException(ex);
}
}
}