Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: lib/command_runner.dart

Issue 1603063004: Don't truncate multi-line command descriptions. (Closed) Base URL: git@github.com:dart-lang/args@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698