/// <summary> /// Constructor. /// </summary> /// <param name="argSet">Argument set to create parser for.</param> /// <param name="options">Parser options.</param> public ArgumentSetParser(ArgumentSetDefinition argSet, CommandLineParserOptions options) { if (argSet == null) { throw new ArgumentNullException(nameof(argSet)); } // Clone the argument set definition, as parsing may mutate it. ArgumentSet = argSet.DeepClone(); // Save off the options provided; if none were provided, construct some quiet defaults. _options = options?.DeepClone() ?? CommandLineParserOptions.Quiet(); // 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(); } }
/// <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); }