forked from pauldotknopf/dotnet-buildary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunner.cs
36 lines (32 loc) · 1.06 KB
/
Runner.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CommandLine;
namespace Build.Buildary
{
public class Runner
{
public static void Execute(RunnerOptions options)
{
var newArgs = new List<string>();
newArgs.Add(options.Target);
Bullseye.Targets.RunTargetsAndExit(newArgs.ToArray());
}
public static T ParseOptions<T>(string[] args) where T: RunnerOptions
{
T result = null;
var parsed = Parser.Default.ParseArguments<T>(args)
.WithParsed(o => { result = o; })
.WithNotParsed(errors => Environment.Exit(1));
return result;
}
public class RunnerOptions
{
[Value(0, Default = "default", HelpText = "The target to run.")]
public string Target { get; set; }
[Option('c', "config", HelpText = "The configuration.", Default = "Release")]
public string Config { get; set; }
}
}
}