OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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:collection'; | 6 import 'dart:collection'; |
7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
8 | 8 |
9 import 'src/arg_parser.dart'; | 9 import 'src/arg_parser.dart'; |
10 import 'src/arg_results.dart'; | 10 import 'src/arg_results.dart'; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 var visible = names.where((name) => !commands[name].hidden); | 364 var visible = names.where((name) => !commands[name].hidden); |
365 if (visible.isNotEmpty) names = visible; | 365 if (visible.isNotEmpty) names = visible; |
366 | 366 |
367 // Show the commands alphabetically. | 367 // Show the commands alphabetically. |
368 names = names.toList()..sort(); | 368 names = names.toList()..sort(); |
369 var length = names.map((name) => name.length).reduce(math.max); | 369 var length = names.map((name) => name.length).reduce(math.max); |
370 | 370 |
371 var buffer = | 371 var buffer = |
372 new StringBuffer('Available ${isSubcommand ? "sub" : ""}commands:'); | 372 new StringBuffer('Available ${isSubcommand ? "sub" : ""}commands:'); |
373 for (var name in names) { | 373 for (var name in names) { |
| 374 var lines = commands[name].description.split("\n"); |
374 buffer.writeln(); | 375 buffer.writeln(); |
375 buffer.write(' ${padRight(name, length)} ' | 376 buffer.write(' ${padRight(name, length)} ${lines.first}'); |
376 '${commands[name].description.split("\n").first}'); | 377 |
| 378 for (var line in lines.skip(1)) { |
| 379 buffer.writeln(); |
| 380 buffer.write(' ' * (length + 5)); |
| 381 buffer.write(line); |
| 382 } |
377 } | 383 } |
378 | 384 |
379 return buffer.toString(); | 385 return buffer.toString(); |
380 } | 386 } |
OLD | NEW |