-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathArguments.cs
More file actions
52 lines (44 loc) · 1.28 KB
/
Arguments.cs
File metadata and controls
52 lines (44 loc) · 1.28 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
50
51
52
using System;
using JenkinsNET.Console.Internal;
using System.Threading;
using System.Threading.Tasks;
using SysConsole = System.Console;
namespace JenkinsNET.Console
{
internal class Arguments : ArgumentsGroup
{
public RunArguments RunGroup {get;}
public Actions Action {get; private set;}
public Arguments()
{
RunGroup = new RunArguments();
Map("run").ToGroup(RunGroup, () => Action = Actions.Run);
Map("-help", "-?").ToAction(v => Action = Actions.Help);
}
public Task RunAsync(CancellationToken token = default)
{
switch (Action) {
case Actions.Run:
return RunGroup.RunAsync(token);
default:
PrintHelp();
break;
}
return Task.CompletedTask;
}
private static void PrintHelp()
{
SysConsole.ResetColor();
SysConsole.WriteLine("Arguments:");
SysConsole.ForegroundColor = ConsoleColor.White;
SysConsole.WriteLine(" run ...");
SysConsole.WriteLine(" -help | -?");
}
public enum Actions
{
Undefined,
Run,
Help,
}
}
}