private void ParseOption(CommandLineOptionBase option, ParseResult <TOption> result)
        {
            bool found = ArgumentManager.TryGetValue(option, out ArgumentModel model);

            if (found && HelpRequested(result, option, model))
            {
                return;
            }
            else if (!found && option.CheckOptionNotFound())
            {
                throw new OptionNotFoundException(option);
            }
            else if (option.ShouldUseDefault(found, model))
            {
                option.UseDefault();

                return;
            }
            else if (found && !option.CanParse(model))
            {
                throw new OptionParseException(option, model);
            }
            else if (!found)
            {
                return;
            }

            option.Parse(model);
        }
Пример #2
0
        private void ParseOption(CommandLineOptionBase option, CommandParserResult result)
        {
            bool found = argumentManager.TryGetValue(option, out ArgumentModel model);

            if (found && HelpRequested(result, option, model))
            {
                logger.LogDebug("Command Option '{Name}' got help requested.", option.ToString());

                return;
            }
            else if (!found && option.CheckOptionNotFound())
            {
                throw new OptionNotFoundException(option);
            }
            else if (option.ShouldUseDefault(found, model))
            {
                logger.LogDebug("Command Option '{Name}' using default value.", option.ToString());

                option.UseDefault();

                return;
            }
            else if (found && !option.CanParse(model))
            {
                throw new OptionParseException(option, model);
            }
            else if (!found)
            {
                return;
            }

            option.Parse(model);
        }