コード例 #1
0
        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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 public static DidactClient Name(this DidactClient didact, string name)
 {
     didact.Metadata.Name = name;
     return(didact);
 }
コード例 #4
0
 public static DidactClient Usage(this DidactClient didact, string usage)
 {
     didact.Metadata.Usage = usage;
     return(didact);
 }
コード例 #5
0
 public static DidactClient Version(this DidactClient didact, string version)
 {
     didact.Metadata.Version = version;
     return(didact);
 }
コード例 #6
0
 public static DidactClient CliName(this DidactClient didact, string cliName)
 {
     didact.Metadata.CliName = cliName;
     return(didact);
 }