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

Unified Diff: lib/src/usage.dart

Issue 1145413002: Add support for separators. (Closed) Base URL: git@github.com:dart-lang/args@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: lib/src/usage.dart
diff --git a/lib/src/usage.dart b/lib/src/usage.dart
index 11be54b38983900ea14ddf0c9223bcb20b2a6923..162dcbde634ac50f4dddc293c61b5cad633627e5 100644
--- a/lib/src/usage.dart
+++ b/lib/src/usage.dart
@@ -62,8 +62,17 @@ class Usage {
calculateColumnWidths();
- args.options.forEach((name, option) {
- if (option.hide) return;
+ for (var optionOrSeparator in args.optionsAndSeparators) {
+ if (optionOrSeparator is String) {
+ // Ensure that there's always a blank line before a separator.
+ if (buffer.isNotEmpty) buffer.write("\n\n");
+ buffer.write(optionOrSeparator);
+ newlinesNeeded = 1;
+ continue;
+ }
+
+ var option = optionOrSeparator;
Bob Nystrom 2015/05/21 16:43:16 Do you need an "as Option" here?
nweiz 2015/05/21 19:22:27 The analyzer infers it as dynamic, so it doesn't p
Bob Nystrom 2015/05/21 19:42:27 Yeah, I think so.
nweiz 2015/05/21 19:52:37 Done.
+ if (option.hide) continue;
write(0, getAbbreviation(option));
write(1, getLongOption(option));
@@ -94,7 +103,7 @@ class Usage {
// blank line after it. This gives space where it's useful while still
// keeping simple one-line options clumped together.
if (numHelpLines > 1) newline();
- });
+ }
return buffer.toString();
}
« lib/src/arg_parser.dart ('K') | « lib/src/arg_parser.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698