OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * The main entrypoint for the pub command line application. | 6 * The main entrypoint for the pub command line application. |
7 */ | 7 */ |
8 #library('pub'); | 8 #library('pub'); |
9 | 9 |
10 #import('../../pkg/args/args.dart'); | 10 #import('../../pkg/args/args.dart'); |
11 #import('dart:io'); | 11 #import('dart:io'); |
| 12 #import('dart:math'); |
12 #import('io.dart'); | 13 #import('io.dart'); |
13 #import('command_help.dart'); | 14 #import('command_help.dart'); |
14 #import('command_install.dart'); | 15 #import('command_install.dart'); |
15 #import('command_list.dart'); | 16 #import('command_list.dart'); |
16 #import('command_update.dart'); | 17 #import('command_update.dart'); |
17 #import('command_version.dart'); | 18 #import('command_version.dart'); |
18 #import('entrypoint.dart'); | 19 #import('entrypoint.dart'); |
19 #import('git_source.dart'); | 20 #import('git_source.dart'); |
20 #import('package.dart'); | 21 #import('package.dart'); |
21 #import('pubspec.dart'); | 22 #import('pubspec.dart'); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 print('Global options:'); | 115 print('Global options:'); |
115 print(pubArgParser.getUsage()); | 116 print(pubArgParser.getUsage()); |
116 print(''); | 117 print(''); |
117 print('The commands are:'); | 118 print('The commands are:'); |
118 | 119 |
119 // Show the commands sorted. | 120 // Show the commands sorted. |
120 // TODO(rnystrom): A sorted map would be nice. | 121 // TODO(rnystrom): A sorted map would be nice. |
121 int length = 0; | 122 int length = 0; |
122 var names = <String>[]; | 123 var names = <String>[]; |
123 for (var command in pubCommands.getKeys()) { | 124 for (var command in pubCommands.getKeys()) { |
124 length = Math.max(length, command.length); | 125 length = max(length, command.length); |
125 names.add(command); | 126 names.add(command); |
126 } | 127 } |
127 | 128 |
128 names.sort((a, b) => a.compareTo(b)); | 129 names.sort((a, b) => a.compareTo(b)); |
129 | 130 |
130 for (var name in names) { | 131 for (var name in names) { |
131 print(' ${padRight(name, length)} ${pubCommands[name].description}'); | 132 print(' ${padRight(name, length)} ${pubCommands[name].description}'); |
132 } | 133 } |
133 | 134 |
134 print(''); | 135 print(''); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 print(''); | 228 print(''); |
228 print('Usage: $usage'); | 229 print('Usage: $usage'); |
229 | 230 |
230 var commandUsage = commandParser.getUsage(); | 231 var commandUsage = commandParser.getUsage(); |
231 if (!commandUsage.isEmpty()) { | 232 if (!commandUsage.isEmpty()) { |
232 print(''); | 233 print(''); |
233 print(commandUsage); | 234 print(commandUsage); |
234 } | 235 } |
235 } | 236 } |
236 } | 237 } |
OLD | NEW |