Chromium Code Reviews| Index: pkg/analyzer/lib/options.dart |
| diff --git a/pkg/analyzer/lib/options.dart b/pkg/analyzer/lib/options.dart |
| index 50519dcfcc18409c41aba31340e972094c6d9528..189ae71f57c3ca85f732887bc1797bfcd50a8f5d 100644 |
| --- a/pkg/analyzer/lib/options.dart |
| +++ b/pkg/analyzer/lib/options.dart |
| @@ -133,7 +133,7 @@ class CommandLineOptions { |
| static CommandLineOptions _parse(List<String> args) { |
| args = args.expand((String arg) => arg.split('=')).toList(); |
| - var parser = new _CommandLineParser() |
| + var parser = new CommandLineParser() |
| ..addFlag( |
| 'batch', |
| abbr: 'b', |
| @@ -208,8 +208,7 @@ class CommandLineOptions { |
| ..addOption( |
| 'url-mapping', |
| help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' |
| - 'analyzer to use "library.dart" as the source for an import ' |
| - 'of "libraryUri"', |
| + 'analyzer to use "library.dart" as the source for an import ' 'of "libraryUri"', |
| allowMultiple: true) |
| // |
| // Hidden flags. |
| @@ -282,7 +281,9 @@ class CommandLineOptions { |
| customUrlMappings[splitMapping[0]] = splitMapping[1]; |
| } |
| return new CommandLineOptions._fromArgs( |
| - results, definedVariables, customUrlMappings); |
| + results, |
| + definedVariables, |
| + customUrlMappings); |
| } on FormatException catch (e) { |
| print(e.message); |
| _showUsage(parser); |
| @@ -305,17 +306,21 @@ class CommandLineOptions { |
| * TODO(pquitslund): when the args package supports ignoring unrecognized |
| * options/flags, this class can be replaced with a simple [ArgParser] instance. |
| */ |
| -class _CommandLineParser { |
| +class CommandLineParser { |
| final List<String> _knownFlags; |
| + final bool _alwaysIgnoreUnrecognized; |
| final ArgParser _parser; |
| /** Creates a new command line parser */ |
| - _CommandLineParser() |
| + CommandLineParser({bool alwaysIgnoreUnrecognized: false}) |
| : _knownFlags = <String>[], |
| + _alwaysIgnoreUnrecognized = alwaysIgnoreUnrecognized, |
| _parser = new ArgParser(allowTrailingOptions: true); |
| + ArgParser get parser => _parser; |
| + |
| /** |
| * Defines a flag. |
| * |
| @@ -393,8 +398,10 @@ class _CommandLineParser { |
| List<String> _filterUnknowns(args) { |
| - // Only filter args if the ignore flag is specified. |
| - if (!args.contains('--ignore-unrecognized-flags')) { |
| + // Only filter args if the ignore flag is specified, or if |
| + // _alwaysIgnoreUnrecognized was set to true |
| + if (_alwaysIgnoreUnrecognized || |
| + !args.contains('--ignore-unrecognized-flags')) { |
|
Brian Wilkerson
2015/02/19 21:58:21
This looks wrong. Previously, we would return imme
|
| return args; |
| } |
| //TODO(pquitslund): replace w/ the following once library skew issues are |