Exemplo n.º 1
0
        /// <summary>
        ///     Adds a positional that has only 1 value
        /// </summary>
        /// <param name="consumeCallback">The consume callback.</param>
        /// <param name="helpSetupCallback">The help setup callback.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <returns>ParserBuilder.</returns>
        public ParserBuilder WithPositional(Action <object, string> consumeCallback,
                                            Action <ParameterHelpBuilder> helpSetupCallback = null, bool required = false)
        {
            var sw = new Positional(Parser, (o, strings) => consumeCallback(o, strings.Single()), 1, 1)
            {
                IsRequired = required
            };

            AddParameterInternal(sw, helpSetupCallback);
            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Adds a positional that can have multiple values
        /// </summary>
        /// <param name="consumeCallback">The consume callback.</param>
        /// <param name="min">The minimum.</param>
        /// <param name="max">The maximum.</param>
        /// <param name="helpSetupCallback">The help setup callback.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <returns>ParserBuilder.</returns>
        public ParserBuilder WithPositionals(Action <object, string[]> consumeCallback, int min = 1,
                                             int max = int.MaxValue, Action <ParameterHelpBuilder> helpSetupCallback = null, bool required = false)
        {
            var sw = new Positional(Parser, consumeCallback, min, max)
            {
                IsRequired = required
            };

            AddParameterInternal(sw, helpSetupCallback);
            return(this);
        }