Last active
August 11, 2019 16:13
-
-
Save adamralph/a98dd9184aa7fa3d66935c32f39de14b to your computer and use it in GitHub Desktop.
Using Bullseye with custom args with System.CommandLine.Experimental
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dotnet add package System.CommandLine.Experimental | |
using System.CommandLine; | |
using static Bullseye.Targets; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var cmd = new RootCommand { TreatUnmatchedTokensAsErrors = false }; | |
cmd.Add(new Option("--foo", "A value used for something.") { Argument = new Argument<string>("foo") }); | |
var cmdLine = cmd.Parse(args); | |
Target("build", () => System.Console.WriteLine($"foo = {cmdLine.ValueForOption<string>("--foo")}")); | |
Target("default", DependsOn("build")); | |
RunTargetsAndExit(cmdLine.UnmatchedTokens); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment