Exemplo n.º 1
0
        public async Task Parse(string[] args)
        {
            IVerbParser    parser  = new HelpVerbParser();
            Stack <string> cliArgs = new Stack <string>();

            if (args.Any())
            {
                cliArgs = new Stack <string>(args.Reverse());
                string verb = cliArgs.Pop();

                parser = _verbParserFactory[verb];
                if (parser == null)
                {
                    throw new ArgumentException("Unrecognized verb!", nameof(verb));
                }
            }

            await parser.Parse(cliArgs);
        }
Exemplo n.º 2
0
        public async Task Parse(string[] args)
        {
            IVerbParser    parser  = new HelpVerbParser();
            Stack <string> cliArgs = new Stack <string>();

            if (args.Any())
            {
                cliArgs = new Stack <string>(args.Reverse());
                string verb = cliArgs.Pop();

                parser = _verbParserFactory[verb];
                if (parser == null)
                {
                    StringBuilder helpBuilder = new StringBuilder()
                                                .AppendLine($"Command '{verb}' is not recognized! Try:")
                                                .AppendLine()
                                                .AppendLine("    boxer help");

                    throw new VerbNotFoundException(helpBuilder.ToString());
                }
            }

            await parser.Parse(cliArgs);
        }