public void ProcessArgs(string[] args, Func <int, string[]> exitFunc)
        {
            var optionParser = new OptionList(this, Context, stopOnFirstNonOption: true);

            optionParser.AdditionalBannerInfo = AdditionalBannerInfo;
            if (args == null || args.Length == 0)
            {
                optionParser.DoHelp();
                return;
            }

            var helpCommand = new HelpCommand(AllCommands, optionParser, Context);

            AllCommands.Add(helpCommand);
            var commands = AllCommands.Distinct(this).OrderBy(command => command.Name.ToLowerInvariant()).ToList();

            AllCommands.Clear();
            AllCommands.AddRange(commands);

            var remainingArgs = optionParser.ProcessArgs(args, exitFunc);
            var commandName   = remainingArgs.FirstOrDefault();
            var commandArgs   = remainingArgs.Skip(1).ToArray();

            if (string.IsNullOrWhiteSpace(commandName))
            {
                optionParser.DoHelp();
                return;
            }

            foreach (var command in AllCommands)
            {
                if (commandName.Equals(command.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    var parser = new OptionList(command, Context);
                    parser.AdditionalBannerInfo = AdditionalBannerInfo;
                    command.Execute(parser.ProcessArgs(commandArgs, exitFunc), Context.ReportError);
                }
            }
        }
        public void Execute(IEnumerable <string> args, ErrorReporter ReportError)
        {
            var commandName = args.FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(commandName))
            {
                foreach (var command in _commands)
                {
                    if (commandName.Equals(command.Name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        var parser = new OptionList(command, _context);
                        parser.DoHelp();
                        return;
                    }
                }
            }
            else
            {
                _optionParser.DoHelp(_commands);
            }
        }