-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainCommand.cs
More file actions
45 lines (37 loc) · 1.25 KB
/
MainCommand.cs
File metadata and controls
45 lines (37 loc) · 1.25 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
using DotMake.CommandLine;
namespace EXDTooler;
[CliCommand]
public sealed class MainCommand
{
[CliOption(Required = false, Hidden = true, Name = "--gha")]
public bool IsGithubActions { get; set; } = false;
[CliOption(Required = false, Description = "Enables verbose logging.")]
public bool Verbose { get; set; }
[CliOption(Required = false, Description = "Enables debug logging. Implies verbose logging.")]
public bool Debug { get; set; }
public CancellationToken Init()
{
#if DEBUG
Log.IsVerboseEnabled = Log.IsDebugEnabled = true;
#else
Log.IsVerboseEnabled = Debug || Verbose;
Log.IsDebugEnabled = Debug;
#endif
Log.Info($"Verbose: {Log.IsVerboseEnabled}; Debug: {Log.IsDebugEnabled}");
Log.IsGHA = IsGithubActions;
if (Log.IsGHA)
Log.Info("Running in CI/CD mode. o/");
var cts = new CancellationTokenSource();
Console.CancelKeyPress += (sender, eventArgs) =>
{
cts.Cancel();
eventArgs.Cancel = true;
};
return cts.Token;
}
private static Task<int> Main(string[] args) =>
Cli.RunAsync<MainCommand>(args, new CliSettings
{
//EnableDefaultExceptionHandler = true
});
}