public static void Main(string[] args) { var didact = new DidactClient() .CliName("gossip-girl") .Name("Gossip Girl Cli Tool") .Version("1.0.0") .Command("add-gossip <word>", "Adds gossip to a word.", (arguments, options) => { const string gossip = "xo"; var word = $"{arguments["word"]} "; var gossips = int.Parse(options["c"]); for (var i = 0; i < gossips; i++) { word += gossip; } Console.WriteLine(word); }).Option("-c, --count [count]", "Number of gossips to add.", validate: (val) => { int gossips = 0; return(Int32.TryParse(val, out gossips)); }, defaultValue: "2"); didact.Parse(args); }
public static void Main(string[] args) { var didact = new DidactClient() .CliName("baelor") .Name("Baelor Cli Client") .Version("1.0.0") .Option("-k, --api-key [api-key]", "The Api Key for your account on baelor.io.") .CommandAsync("get-album <album>", "Get's details of a Taylor Swift album.", GetAlbum) .CommandAsync("get-lyrics <song>", "Gets the lyric of a Taylor Swift song.", GetLyricsToSong) .Option("-h, --hide-timecodes [hide-timecodes]", "Toggles the visibility of Timecodes", validate: (val) => { var lowerVal = val.ToLowerInvariant(); return(lowerVal == "t" || lowerVal == "f"); }, defaultValue: "t"); try { didact.ParseAsync(args).Wait(); } catch (AggregateException ex) { ExceptionDispatchInfo.Capture(ex.Flatten().InnerExceptions.First()).Throw(); } }
public static DidactClient Name(this DidactClient didact, string name) { didact.Metadata.Name = name; return(didact); }
public static DidactClient Usage(this DidactClient didact, string usage) { didact.Metadata.Usage = usage; return(didact); }
public static DidactClient Version(this DidactClient didact, string version) { didact.Metadata.Version = version; return(didact); }
public static DidactClient CliName(this DidactClient didact, string cliName) { didact.Metadata.CliName = cliName; return(didact); }