예제 #1
0
        public Command Create()
        {
            var command = new Command("people", "List people available on this project");

            command.AddOption(new Option(new string[] { "--verbose", "-v" }, "if provided, it will also print the age of the people")
            {
                Argument = new Argument <bool>(() => false)
            });

            command.Handler = CommandHandler.Create <bool>(verbose =>
            {
                foreach (Person person in _people.List())
                {
                    Console.WriteLine(verbose ? $"{person.Name,-20} {person.Age.ToString()}" : person.Name.ToString());
                }
            });

            return(command);
        }
예제 #2
0
        public Command Create()
        {
            var command = new Command("emoticons", "List all emoticons available on this project");

            command.AddOption(new Option(new string[] { "--verbose", "-v" }, "if provided, it will also print the name of the emoticon")
            {
                Argument = new Argument <bool>(() => false)
            });

            command.Handler = CommandHandler.Create <bool>((bool verbose) =>
            {
                foreach (Emoticon emoticon in _emoticons.List())
                {
                    Console.WriteLine(verbose ? $"{emoticon.Name,-20} {emoticon.Emoji}" : emoticon.Emoji);
                }
            });

            return(command);
        }