Chromium Code Reviews| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 | 8 |
| 9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| 11 | 11 |
| 12 import '../lib/src/command.dart'; | 12 import '../lib/src/command.dart'; |
| 13 import '../lib/src/exit_codes.dart' as exit_codes; | 13 import '../lib/src/exit_codes.dart' as exit_codes; |
| 14 import '../lib/src/io.dart'; | 14 import '../lib/src/io.dart'; |
| 15 import '../lib/src/log.dart' as log; | 15 import '../lib/src/log.dart' as log; |
| 16 import '../lib/src/sdk.dart' as sdk; | 16 import '../lib/src/sdk.dart' as sdk; |
| 17 import '../lib/src/utils.dart'; | 17 import '../lib/src/utils.dart'; |
| 18 | 18 |
| 19 final pubArgParser = initArgParser(); | 19 final pubArgParser = initArgParser(); |
| 20 | 20 |
| 21 void main() { | 21 void main(List<String> arguments) { |
| 22 ArgResults options; | 22 ArgResults options; |
| 23 // Keep the command line args, to print in any user error message. | |
| 24 PubCommand.errorArguments = arguments; | |
|
Bob Nystrom
2013/10/29 16:58:52
Pass this into PubCommand.run instead.
Bill Hesse
2013/10/29 17:16:29
Done.
| |
| 23 | 25 |
| 24 try { | 26 try { |
| 25 options = pubArgParser.parse(new Options().arguments); | 27 options = pubArgParser.parse(arguments); |
| 26 } on FormatException catch (e) { | 28 } on FormatException catch (e) { |
| 27 log.error(e.message); | 29 log.error(e.message); |
| 28 log.error('Run "pub help" to see available options.'); | 30 log.error('Run "pub help" to see available options.'); |
| 29 flushThenExit(exit_codes.USAGE); | 31 flushThenExit(exit_codes.USAGE); |
| 30 return; | 32 return; |
| 31 } | 33 } |
| 32 | 34 |
| 33 if (options['version']) { | 35 if (options['version']) { |
| 34 log.message('Pub ${sdk.version}'); | 36 log.message('Pub ${sdk.version}'); |
| 35 return; | 37 return; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 for (var name in names) { | 167 for (var name in names) { |
| 166 buffer.write(' ${padRight(name, length)} ' | 168 buffer.write(' ${padRight(name, length)} ' |
| 167 '${PubCommand.commands[name].description}\n'); | 169 '${PubCommand.commands[name].description}\n'); |
| 168 } | 170 } |
| 169 | 171 |
| 170 buffer.write('\n'); | 172 buffer.write('\n'); |
| 171 buffer.write( | 173 buffer.write( |
| 172 'Use "pub help [command]" for more information about a command.'); | 174 'Use "pub help [command]" for more information about a command.'); |
| 173 log.message(buffer.toString()); | 175 log.message(buffer.toString()); |
| 174 } | 176 } |
| OLD | NEW |