Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.