Skip to content

Instantly share code, notes, and snippets.

@adamralph
Last active August 11, 2019 16:13
Show Gist options
  • Save adamralph/a98dd9184aa7fa3d66935c32f39de14b to your computer and use it in GitHub Desktop.
Save adamralph/a98dd9184aa7fa3d66935c32f39de14b to your computer and use it in GitHub Desktop.
Using Bullseye with custom args with System.CommandLine.Experimental
// 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