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

Unified Diff: lib/args/args.dart

Issue 10828351: Added the ability to get the names of the options in a set of parsed arguments, and the default val… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/args/args.dart
===================================================================
--- lib/args/args.dart (revision 10607)
+++ lib/args/args.dart (working copy)
@@ -489,6 +489,14 @@
return null;
}
+
+ /**
+ * Get the default value for an option. Useful after parsing to test
+ * if the user specified something other than the default.
Bob Nystrom 2012/08/16 21:26:58 This method is useful in its own right, but if it'
gram 2012/08/16 21:55:53 ArgResults does not have that information. We coul
+ */
+
+ getDefault(String option) => _options.containsKey(option) ?
+ _options[option].defaultValue : null;
Bob Nystrom 2012/08/16 21:26:58 If the option name is invalid, this should throw a
gram 2012/08/16 21:55:53 Done. I assume you mean IllegalArgument...
}
/**
@@ -518,6 +526,9 @@
return _options[name];
}
+
+ /** Get the names of the options as a [Collection]. */
+ Collection<String> get options => _options.getKeys();
Bob Nystrom 2012/08/16 21:26:58 Instead of this, how about making ArgResults imple
gram 2012/08/16 21:55:53 That seems like a lot of extra effort. All I want
}
class _Option {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698