| 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 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 enable support for the proposed async feature. */ | 29 /** Whether to enable support for the proposed async feature. */ |
| 30 final bool enableAsync; | 30 final bool enableAsync; |
| 31 | 31 |
| 32 /** Whether to enable support for the proposed enum feature. */ | 32 /** Whether to enable support for the proposed enum feature. */ |
| 33 final bool enableEnum; | 33 final bool enableEnum; |
| 34 | 34 |
| 35 /** |
| 36 * Whether to treat type mismatches found during constant evaluation as |
| 37 * errors. |
| 38 */ |
| 39 final bool enableTypeChecks; |
| 40 |
| 35 /** Whether to ignore unrecognized flags */ | 41 /** Whether to ignore unrecognized flags */ |
| 36 final bool ignoreUnrecognizedFlags; | 42 final bool ignoreUnrecognizedFlags; |
| 37 | 43 |
| 38 /** Whether to log additional analysis messages and exceptions */ | 44 /** Whether to log additional analysis messages and exceptions */ |
| 39 final bool log; | 45 final bool log; |
| 40 | 46 |
| 41 /** Whether to use machine format for error display */ | 47 /** Whether to use machine format for error display */ |
| 42 final bool machineFormat; | 48 final bool machineFormat; |
| 43 | 49 |
| 44 /** The path to the package root */ | 50 /** The path to the package root */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 68 /** | 74 /** |
| 69 * Initialize options from the given parsed [args]. | 75 * Initialize options from the given parsed [args]. |
| 70 */ | 76 */ |
| 71 CommandLineOptions._fromArgs(ArgResults args, Map<String, String> definedVaria
bles) | 77 CommandLineOptions._fromArgs(ArgResults args, Map<String, String> definedVaria
bles) |
| 72 : dartSdkPath = args['dart-sdk'], | 78 : dartSdkPath = args['dart-sdk'], |
| 73 this.definedVariables = definedVariables, | 79 this.definedVariables = definedVariables, |
| 74 disableHints = args['no-hints'], | 80 disableHints = args['no-hints'], |
| 75 displayVersion = args['version'], | 81 displayVersion = args['version'], |
| 76 enableAsync = args['enable-async'], | 82 enableAsync = args['enable-async'], |
| 77 enableEnum = args['enable-enum'], | 83 enableEnum = args['enable-enum'], |
| 84 enableTypeChecks = args['enable_type_checks'], |
| 78 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], | 85 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], |
| 79 log = args['log'], | 86 log = args['log'], |
| 80 machineFormat = args['machine'] || args['format'] == 'machine', | 87 machineFormat = args['machine'] || args['format'] == 'machine', |
| 81 packageRootPath = args['package-root'], | 88 packageRootPath = args['package-root'], |
| 82 perf = args['perf'], | 89 perf = args['perf'], |
| 83 shouldBatch = args['batch'], | 90 shouldBatch = args['batch'], |
| 84 showPackageWarnings = args['show-package-warnings'] || args['package-warni
ngs'], | 91 showPackageWarnings = args['show-package-warnings'] || args['package-warni
ngs'], |
| 85 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], | 92 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], |
| 86 sourceFiles = args.rest, | 93 sourceFiles = args.rest, |
| 87 warmPerf = args['warm-perf'], | 94 warmPerf = args['warm-perf'], |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 ..addFlag('enable-async', | 161 ..addFlag('enable-async', |
| 155 help: 'Enable support for the proposed async feature', | 162 help: 'Enable support for the proposed async feature', |
| 156 defaultsTo: false, negatable: false, hide: true) | 163 defaultsTo: false, negatable: false, hide: true) |
| 157 ..addFlag('enable-enum', | 164 ..addFlag('enable-enum', |
| 158 help: 'Enable support for the proposed enum feature', | 165 help: 'Enable support for the proposed enum feature', |
| 159 defaultsTo: false, negatable: false, hide: true) | 166 defaultsTo: false, negatable: false, hide: true) |
| 160 ..addFlag('log', help: 'Log additional messages and exceptions', | 167 ..addFlag('log', help: 'Log additional messages and exceptions', |
| 161 defaultsTo: false, negatable: false, hide: true) | 168 defaultsTo: false, negatable: false, hide: true) |
| 162 ..addFlag('warm-perf', | 169 ..addFlag('warm-perf', |
| 163 help: 'Show both cold and warm performance statistics', | 170 help: 'Show both cold and warm performance statistics', |
| 171 defaultsTo: false, negatable: false, hide: true) |
| 172 ..addFlag('enable_type_checks', |
| 173 help: 'Check types in constant evaluation', |
| 164 defaultsTo: false, negatable: false, hide: true); | 174 defaultsTo: false, negatable: false, hide: true); |
| 165 | 175 |
| 166 try { | 176 try { |
| 167 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 | 177 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 |
| 168 args = args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(
); | 178 args = args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(
); |
| 169 Map<String, String> definedVariables = <String, String>{}; | 179 Map<String, String> definedVariables = <String, String>{}; |
| 170 var results = parser.parse(args, definedVariables); | 180 var results = parser.parse(args, definedVariables); |
| 171 // help requests | 181 // help requests |
| 172 if (results['help']) { | 182 if (results['help']) { |
| 173 _showUsage(parser); | 183 _showUsage(parser); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 340 |
| 331 _getNextFlagIndex(args, i) { | 341 _getNextFlagIndex(args, i) { |
| 332 for ( ; i < args.length; ++i) { | 342 for ( ; i < args.length; ++i) { |
| 333 if (args[i].startsWith('--')) { | 343 if (args[i].startsWith('--')) { |
| 334 return i; | 344 return i; |
| 335 } | 345 } |
| 336 } | 346 } |
| 337 return i; | 347 return i; |
| 338 } | 348 } |
| 339 } | 349 } |
| OLD | NEW |