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

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 | tests/lib/args/args_test.dart » ('j') | 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,17 @@
return null;
}
+
+ /**
+ * Get the default value for an option. Useful after parsing to test
+ * if the user specified something other than the default.
+ */
+ getDefault(String option) {
+ if (!_options.containsKey(option)) {
+ throw new IllegalArgumentException('No option named $option');
+ }
+ return _options[option].defaultValue;
+ }
}
/**
@@ -518,6 +529,9 @@
return _options[name];
}
+
+ /** Get the names of the options as a [Collection]. */
+ Collection<String> get options => _options.getKeys();
}
class _Option {
« no previous file with comments | « no previous file | tests/lib/args/args_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698