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 | 9 |
9 import 'dart:io'; | 10 import 'dart:io'; |
10 | 11 |
11 | 12 |
12 const _BINARY_NAME = 'dartanalyzer'; | 13 const _BINARY_NAME = 'dartanalyzer'; |
13 | 14 |
14 /** | 15 /** |
15 * Analyzer commandline configuration options. | 16 * Analyzer commandline configuration options. |
16 */ | 17 */ |
17 class CommandLineOptions { | 18 class CommandLineOptions { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 147 |
147 static _showUsage(parser) { | 148 static _showUsage(parser) { |
148 print('Usage: $_BINARY_NAME [options...] <libraries to analyze...>'); | 149 print('Usage: $_BINARY_NAME [options...] <libraries to analyze...>'); |
149 print(parser.getUsage()); | 150 print(parser.getUsage()); |
150 print(''); | 151 print(''); |
151 print('For more information, see http://www.dartlang.org/tools/analyzer.'); | 152 print('For more information, see http://www.dartlang.org/tools/analyzer.'); |
152 } | 153 } |
153 | 154 |
154 static String _getVersion() { | 155 static String _getVersion() { |
155 try { | 156 try { |
156 Path path = new Path(Platform.script); | 157 Path versionPath = join(dirname(Platform.script), '..', 'version');; |
157 Path versionPath = path.directoryPath.append('..').append('version'); | |
158 File versionFile = new File.fromPath(versionPath); | 158 File versionFile = new File.fromPath(versionPath); |
159 return versionFile.readAsStringSync().trim(); | 159 return versionFile.readAsStringSync().trim(); |
160 } catch (_) { | 160 } catch (_) { |
161 // This happens when the script is not running in the context of an SDK. | 161 // This happens when the script is not running in the context of an SDK. |
162 return "<unknown>"; | 162 return "<unknown>"; |
163 } | 163 } |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 /** | 167 /** |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 _getNextFlagIndex(args, i) { | 257 _getNextFlagIndex(args, i) { |
258 for ( ; i < args.length; ++i) { | 258 for ( ; i < args.length; ++i) { |
259 if (args[i].startsWith('--')) { | 259 if (args[i].startsWith('--')) { |
260 return i; | 260 return i; |
261 } | 261 } |
262 } | 262 } |
263 return i; | 263 return i; |
264 } | 264 } |
265 } | 265 } |
OLD | NEW |