| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library options; | 5 library options; |
| 6 | 6 |
| 7 import 'package:args/args.dart'; | 7 import 'package:args/args.dart'; |
| 8 import 'package:path/path.dart'; | 8 import 'package:path/path.dart'; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 /** Whether to use machine format for error display */ | 23 /** Whether to use machine format for error display */ |
| 24 final bool machineFormat; | 24 final bool machineFormat; |
| 25 | 25 |
| 26 /** Whether to display version information */ | 26 /** Whether to display version information */ |
| 27 final bool displayVersion; | 27 final bool displayVersion; |
| 28 | 28 |
| 29 /** Whether to ignore unrecognized flags */ | 29 /** Whether to ignore unrecognized flags */ |
| 30 final bool ignoreUnrecognizedFlags; | 30 final bool ignoreUnrecognizedFlags; |
| 31 | 31 |
| 32 /** Whether to show performance statistics */ |
| 33 final bool perf; |
| 34 |
| 32 /** Whether to show package: warnings */ | 35 /** Whether to show package: warnings */ |
| 33 final bool showPackageWarnings; | 36 final bool showPackageWarnings; |
| 34 | 37 |
| 35 /** Whether to show SDK warnings */ | 38 /** Whether to show SDK warnings */ |
| 36 final bool showSdkWarnings; | 39 final bool showSdkWarnings; |
| 37 | 40 |
| 38 /** Whether to treat warnings as fatal */ | 41 /** Whether to treat warnings as fatal */ |
| 39 final bool warningsAreFatal; | 42 final bool warningsAreFatal; |
| 40 | 43 |
| 41 /** The path to the dart SDK */ | 44 /** The path to the dart SDK */ |
| 42 final String dartSdkPath; | 45 final String dartSdkPath; |
| 43 | 46 |
| 44 /** The path to the package root */ | 47 /** The path to the package root */ |
| 45 final String packageRootPath; | 48 final String packageRootPath; |
| 46 | 49 |
| 47 /** The source files to analyze */ | 50 /** The source files to analyze */ |
| 48 final List<String> sourceFiles; | 51 final List<String> sourceFiles; |
| 49 | 52 |
| 50 /** | 53 /** |
| 51 * Initialize options from the given parsed [args]. | 54 * Initialize options from the given parsed [args]. |
| 52 */ | 55 */ |
| 53 CommandLineOptions._fromArgs(ArgResults args) | 56 CommandLineOptions._fromArgs(ArgResults args) |
| 54 : shouldBatch = args['batch'], | 57 : shouldBatch = args['batch'], |
| 55 machineFormat = args['machine'], | 58 machineFormat = args['machine'], |
| 56 displayVersion = args['version'], | 59 displayVersion = args['version'], |
| 57 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], | 60 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], |
| 61 perf = args['perf'], |
| 58 showPackageWarnings = args['show-package-warnings'], | 62 showPackageWarnings = args['show-package-warnings'], |
| 59 showSdkWarnings = args['show-sdk-warnings'], | 63 showSdkWarnings = args['show-sdk-warnings'], |
| 60 warningsAreFatal = args['fatal-warnings'], | 64 warningsAreFatal = args['fatal-warnings'], |
| 61 dartSdkPath = args['dart-sdk'], | 65 dartSdkPath = args['dart-sdk'], |
| 62 packageRootPath = args['package-root'], | 66 packageRootPath = args['package-root'], |
| 63 sourceFiles = args.rest; | 67 sourceFiles = args.rest; |
| 64 | 68 |
| 65 /** | 69 /** |
| 66 * Parse [args] into [CommandLineOptions] describing the specified | 70 * Parse [args] into [CommandLineOptions] describing the specified |
| 67 * analyzer options. In case of a format error, prints error and exists. | 71 * analyzer options. In case of a format error, prints error and exists. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 ..addFlag('version', help: 'Print the analyzer version', | 103 ..addFlag('version', help: 'Print the analyzer version', |
| 100 defaultsTo: false, negatable: false) | 104 defaultsTo: false, negatable: false) |
| 101 ..addFlag('ignore-unrecognized-flags', | 105 ..addFlag('ignore-unrecognized-flags', |
| 102 help: 'Ignore unrecognized command line flags', | 106 help: 'Ignore unrecognized command line flags', |
| 103 defaultsTo: false, negatable: false) | 107 defaultsTo: false, negatable: false) |
| 104 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal', | 108 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal', |
| 105 defaultsTo: false, negatable: false) | 109 defaultsTo: false, negatable: false) |
| 106 ..addFlag('show-package-warnings', | 110 ..addFlag('show-package-warnings', |
| 107 help: 'Show warnings from package: imports', | 111 help: 'Show warnings from package: imports', |
| 108 defaultsTo: false, negatable: false) | 112 defaultsTo: false, negatable: false) |
| 113 ..addFlag('perf', |
| 114 help: 'Show performance statistics', |
| 115 defaultsTo: false, negatable: false) |
| 109 ..addFlag('show-sdk-warnings', help: 'Show warnings from SDK imports', | 116 ..addFlag('show-sdk-warnings', help: 'Show warnings from SDK imports', |
| 110 defaultsTo: false, negatable: false) | 117 defaultsTo: false, negatable: false) |
| 111 ..addFlag('help', abbr: 'h', help: 'Display this help message', | 118 ..addFlag('help', abbr: 'h', help: 'Display this help message', |
| 112 defaultsTo: false, negatable: false); | 119 defaultsTo: false, negatable: false); |
| 113 | 120 |
| 114 try { | 121 try { |
| 115 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 | 122 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 |
| 116 args = args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(
); | 123 args = args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(
); |
| 117 var results = parser.parse(args); | 124 var results = parser.parse(args); |
| 118 // help requests | 125 // help requests |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 263 |
| 257 _getNextFlagIndex(args, i) { | 264 _getNextFlagIndex(args, i) { |
| 258 for ( ; i < args.length; ++i) { | 265 for ( ; i < args.length; ++i) { |
| 259 if (args[i].startsWith('--')) { | 266 if (args[i].startsWith('--')) { |
| 260 return i; | 267 return i; |
| 261 } | 268 } |
| 262 } | 269 } |
| 263 return i; | 270 return i; |
| 264 } | 271 } |
| 265 } | 272 } |
| OLD | NEW |