Ejemplo n.º 1
0
        /// <summary>
        /// Constructs an empty argument set.
        /// </summary>
        /// <param name="options">Optionally provides additional options
        /// controlling how parsing proceeds.</param>
        /// <param name="setAttribute">Optionally provides attribute information
        /// describing the attribute set.</param>
        public ArgumentSetDefinition(CommandLineParserOptions options = null, ArgumentSetAttribute setAttribute = null)
        {
            // Save off the options provided; if none were provided, construct some defaults.
            _options = options?.Clone() ?? new CommandLineParserOptions();

            // Save off set attributes; if none were provided, construct some defaults.
            Attribute = setAttribute ?? new ArgumentSetAttribute();

            // Set up private fields dependent on the ArgumentSetAttribute.
            _namedArgumentsByName = new Dictionary <string, ArgumentDefinition>(StringComparerToUse);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new command-line argument parser.
        /// </summary>
        /// <param name="type">Destination object type.</param>
        /// <param name="defaultValues">Optionally provides an object with
        /// default values.</param>
        /// <param name="options">Optionally provides additional options
        /// controlling how parsing proceeds.</param>
        public CommandLineParserEngine(Type type, object defaultValues = null, CommandLineParserOptions options = null)
        {
            // Save off the options provided; if none were provided, construct
            // some defaults.
            _options = options?.Clone() ?? new CommandLineParserOptions();

            // If no reporter was provided, use a no-op one.
            if (_options.Reporter == null)
            {
                _options.Reporter = err => { };
            }

            // If no file-system reader was provided, use our default implementation.
            if (_options.FileSystemReader == null)
            {
                _options.FileSystemReader = FileSystemReader.Create();
            }

            // Define the argument set.
            _argumentSet = new ArgumentSetDefinition(type, defaultValues, _options);
        }