-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathProgram.cs
32 lines (27 loc) · 1.04 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
using Ookii.CommandLine;
using Ookii.CommandLine.Commands;
namespace Samples.RpcBenchmark;
public static class Program
{
public static readonly string DefaultUrl = "https://localhost:22444/";
public static readonly CancellationTokenSource StopTokenSource = new();
public static readonly CancellationToken StopToken = StopTokenSource.Token;
public static async Task<int> Main(string[] args)
{
TreatControlCAsInput = false;
CancelKeyPress += (_, ea) => {
StopTokenSource.Cancel();
ea.Cancel = true;
};
if (args.Length == 0)
return await new TestCommand().RunAsync();
var options = new CommandOptions() {
ArgumentNamePrefixes = new [] { "-" },
CommandNameTransform = NameTransform.DashCase,
ArgumentNameTransform = NameTransform.DashCase,
StripCommandNameSuffix = "Command",
};
var commandManager = new CommandManager(options);
return await commandManager.RunCommandAsync(args) ?? 1;
}
}