Esempio n. 1
0
        static void Main(string[] args)
        {
            ICowsay cowsay = new Cowsay();

            if (args.Length == 0)
            {
                //Console.WriteLine("Print the error message.");
                Console.WriteLine(cowsay.GetVersion());
            }

            if (args.Length == 1)
            {
                var option = args.First();
                if (option == "--version" || option == "-v")
                {
                    Console.WriteLine(cowsay.GetVersion());
                }

                if (option == "--help" || option == "-h")
                {
                    Console.WriteLine("Print the help.");
                }
            }

            //Console.WriteLine(cowsay.SayMessage("Hi"));
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ICowsay cowsay = new Cowsay();

            CommandLineApplication commandLineApplication =
                new CommandLineApplication(throwOnUnexpectedArg: false);
            CommandArgument text = null;

            commandLineApplication.Command("say",
                                           (target) =>
                                           text = target.Argument(
                                               "say",
                                               "Prints the given text to the console as if a cow had said it."));
            commandLineApplication.VersionOption("-v | --version", () => cowsay.GetVersion());
            commandLineApplication.HelpOption("-? | -h | --help");
            commandLineApplication.OnExecute(() =>
            {
                return(0);
            });
            commandLineApplication.Execute(args);
        }