public ParserConfiguration(
            IReadOnlyCollection <Option> definedOptions,
            IReadOnlyCollection <char> argumentDelimiters = null,
            bool allowUnbundling = true)
        {
            if (definedOptions == null)
            {
                throw new ArgumentNullException(nameof(definedOptions));
            }

            if (!definedOptions.Any())
            {
                throw new ArgumentException("You must specify at least one option.");
            }

            if (definedOptions.All(o => !o.IsCommand))
            {
                RootCommand = Create.RootCommand(definedOptions.ToArray());
                DefinedOptions.Add(RootCommand);
            }
            else
            {
                DefinedOptions.AddRange(definedOptions);
            }

            ArgumentDelimiters = argumentDelimiters ?? new[] { ':', '=' };
            AllowUnbundling    = allowUnbundling;
        }
        public Parser(params Option[] options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            DefinedOptions.AddRange(options);
        }
        protected internal Option(
            string[] aliases,
            string help,
            ArgumentsRule arguments = null,
            Option[] options        = null,
            Func <AppliedOption, object> materialize = null)
        {
            if (aliases == null)
            {
                throw new ArgumentNullException(nameof(aliases));
            }

            if (!aliases.Any())
            {
                throw new ArgumentException("An option must have at least one alias.");
            }

            if (aliases.Any(string.IsNullOrWhiteSpace))
            {
                throw new ArgumentException("An option alias cannot be null, empty, or consist entirely of whitespace.");
            }

            foreach (var alias in aliases)
            {
                this.aliases.Add(alias.RemovePrefix());
            }

            HelpText = help;

            Name = aliases
                   .Select(a => a.RemovePrefix())
                   .OrderBy(a => a.Length)
                   .Last();

            this.materialize = materialize;

            if (options != null && options.Any())
            {
                foreach (var option in options)
                {
                    option.Parent = this;
                    DefinedOptions.Add(option);
                }
            }

            ArgumentsRule = arguments ?? Accept.NoArguments;

            if (options != null)
            {
                ArgumentsRule = Accept.ZeroOrMoreOf(options).And(ArgumentsRule);
            }

            AllowedValues = ArgumentsRule.AllowedValues;

            suggest = ArgumentsRule.Suggest;
        }
        public ParserConfiguration(
            IReadOnlyCollection <Option> definedOptions,
            IReadOnlyCollection <char> argumentDelimiters = null)
        {
            if (definedOptions == null)
            {
                throw new ArgumentNullException(nameof(definedOptions));
            }

            if (!definedOptions.Any())
            {
                throw new ArgumentException("You must specify at least one option.");
            }

            DefinedOptions.AddRange(definedOptions);
            ArgumentDelimiters = argumentDelimiters ?? new[] { ':', '=' };
        }