| 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'; |
| 11 | 11 |
| 12 | 12 |
| 13 const _BINARY_NAME = 'dartanalyzer'; | 13 const _BINARY_NAME = 'dartanalyzer'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Analyzer commandline configuration options. | 16 * Analyzer commandline configuration options. |
| 17 */ | 17 */ |
| 18 class CommandLineOptions { | 18 class CommandLineOptions { |
| 19 | 19 |
| 20 /** Batch mode (for unit testing) */ | 20 /** Batch mode (for unit testing) */ |
| 21 final bool shouldBatch; | 21 final bool shouldBatch; |
| 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 report hints */ |
| 30 final bool disableHints; |
| 31 |
| 29 /** Whether to ignore unrecognized flags */ | 32 /** Whether to ignore unrecognized flags */ |
| 30 final bool ignoreUnrecognizedFlags; | 33 final bool ignoreUnrecognizedFlags; |
| 31 | 34 |
| 32 /** Whether to show performance statistics */ | 35 /** Whether to show performance statistics */ |
| 33 final bool perf; | 36 final bool perf; |
| 34 | 37 |
| 35 /** Whether to show package: warnings */ | 38 /** Whether to show package: warnings */ |
| 36 final bool showPackageWarnings; | 39 final bool showPackageWarnings; |
| 37 | 40 |
| 38 /** Whether to show SDK warnings */ | 41 /** Whether to show SDK warnings */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 /** The source files to analyze */ | 53 /** The source files to analyze */ |
| 51 final List<String> sourceFiles; | 54 final List<String> sourceFiles; |
| 52 | 55 |
| 53 /** | 56 /** |
| 54 * Initialize options from the given parsed [args]. | 57 * Initialize options from the given parsed [args]. |
| 55 */ | 58 */ |
| 56 CommandLineOptions._fromArgs(ArgResults args) | 59 CommandLineOptions._fromArgs(ArgResults args) |
| 57 : shouldBatch = args['batch'], | 60 : shouldBatch = args['batch'], |
| 58 machineFormat = args['machine'], | 61 machineFormat = args['machine'], |
| 59 displayVersion = args['version'], | 62 displayVersion = args['version'], |
| 63 disableHints = args['no-hints'], |
| 60 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], | 64 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], |
| 61 perf = args['perf'], | 65 perf = args['perf'], |
| 62 showPackageWarnings = args['show-package-warnings'], | 66 showPackageWarnings = args['show-package-warnings'], |
| 63 showSdkWarnings = args['show-sdk-warnings'], | 67 showSdkWarnings = args['show-sdk-warnings'], |
| 64 warningsAreFatal = args['fatal-warnings'], | 68 warningsAreFatal = args['fatal-warnings'], |
| 65 dartSdkPath = args['dart-sdk'], | 69 dartSdkPath = args['dart-sdk'], |
| 66 packageRootPath = args['package-root'], | 70 packageRootPath = args['package-root'], |
| 67 sourceFiles = args.rest; | 71 sourceFiles = args.rest; |
| 68 | 72 |
| 69 /** | 73 /** |
| (...skipping 25 matching lines...) Expand all Loading... |
| 95 var parser = new _CommandLineParser() | 99 var parser = new _CommandLineParser() |
| 96 ..addFlag('batch', abbr: 'b', help: 'Run in batch mode', | 100 ..addFlag('batch', abbr: 'b', help: 'Run in batch mode', |
| 97 defaultsTo: false, negatable: false) | 101 defaultsTo: false, negatable: false) |
| 98 ..addOption('dart-sdk', help: 'The path to the Dart SDK') | 102 ..addOption('dart-sdk', help: 'The path to the Dart SDK') |
| 99 ..addOption('package-root', help: 'The path to the package root') | 103 ..addOption('package-root', help: 'The path to the package root') |
| 100 ..addFlag('machine', | 104 ..addFlag('machine', |
| 101 help: 'Print errors in a format suitable for parsing', | 105 help: 'Print errors in a format suitable for parsing', |
| 102 defaultsTo: false, negatable: false) | 106 defaultsTo: false, negatable: false) |
| 103 ..addFlag('version', help: 'Print the analyzer version', | 107 ..addFlag('version', help: 'Print the analyzer version', |
| 104 defaultsTo: false, negatable: false) | 108 defaultsTo: false, negatable: false) |
| 109 ..addFlag('no-hints', help: 'Do not show hint results', |
| 110 defaultsTo: false, negatable: false) |
| 105 ..addFlag('ignore-unrecognized-flags', | 111 ..addFlag('ignore-unrecognized-flags', |
| 106 help: 'Ignore unrecognized command line flags', | 112 help: 'Ignore unrecognized command line flags', |
| 107 defaultsTo: false, negatable: false) | 113 defaultsTo: false, negatable: false) |
| 108 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal', | 114 ..addFlag('fatal-warnings', help: 'Treat non-type warnings as fatal', |
| 109 defaultsTo: false, negatable: false) | 115 defaultsTo: false, negatable: false) |
| 110 ..addFlag('show-package-warnings', | 116 ..addFlag('show-package-warnings', |
| 111 help: 'Show warnings from package: imports', | 117 help: 'Show warnings from package: imports', |
| 112 defaultsTo: false, negatable: false) | 118 defaultsTo: false, negatable: false) |
| 113 ..addFlag('perf', | 119 ..addFlag('perf', |
| 114 help: 'Show performance statistics', | 120 help: 'Show performance statistics', |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 269 |
| 264 _getNextFlagIndex(args, i) { | 270 _getNextFlagIndex(args, i) { |
| 265 for ( ; i < args.length; ++i) { | 271 for ( ; i < args.length; ++i) { |
| 266 if (args[i].startsWith('--')) { | 272 if (args[i].startsWith('--')) { |
| 267 return i; | 273 return i; |
| 268 } | 274 } |
| 269 } | 275 } |
| 270 return i; | 276 return i; |
| 271 } | 277 } |
| 272 } | 278 } |
| OLD | NEW |