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

Side by Side Diff: pkg/args/lib/args.dart

Issue 10947044: Commit patch: https://codereview.chromium.org/10914320/ (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/args/test/args_test.dart » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * This library lets you define parsers for parsing raw command-line arguments 6 * This library lets you define parsers for parsing raw command-line arguments
7 * into a set of options and values using [GNU][] and [POSIX][] style options. 7 * into a set of options and values using [GNU][] and [POSIX][] style options.
8 * 8 *
9 * ## Defining options ## 9 * ## Defining options ##
10 * 10 *
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 /** 234 /**
235 * Defines a value-taking option. Throws an [IllegalArgumentException] if: 235 * Defines a value-taking option. Throws an [IllegalArgumentException] if:
236 * 236 *
237 * * There is already an option with name [name]. 237 * * There is already an option with name [name].
238 * * There is already an option using abbreviation [abbr]. 238 * * There is already an option using abbreviation [abbr].
239 */ 239 */
240 void addOption(String name, [String abbr, String help, List<String> allowed, 240 void addOption(String name, [String abbr, String help, List<String> allowed,
241 Map<String, String> allowedHelp, String defaultsTo, 241 Map<String, String> allowedHelp, String defaultsTo,
242 void callback(bool value), bool allowMultiple = false]) { 242 void callback(value), bool allowMultiple = false]) {
243 _addOption(name, abbr, help, allowed, allowedHelp, defaultsTo, 243 _addOption(name, abbr, help, allowed, allowedHelp, defaultsTo,
244 callback, isFlag: false, allowMultiple: allowMultiple); 244 callback, isFlag: false, allowMultiple: allowMultiple);
245 } 245 }
246 246
247 void _addOption(String name, String abbr, String help, List<String> allowed, 247 void _addOption(String name, String abbr, String help, List<String> allowed,
248 Map<String, String> allowedHelp, defaultsTo, 248 Map<String, String> allowedHelp, defaultsTo,
249 void callback(bool value), [bool isFlag, bool negatable = false, 249 void callback(value), [bool isFlag, bool negatable = false,
250 bool allowMultiple = false]) { 250 bool allowMultiple = false]) {
251 // Make sure the name isn't in use. 251 // Make sure the name isn't in use.
252 if (_options.containsKey(name)) { 252 if (_options.containsKey(name)) {
253 throw new IllegalArgumentException('Duplicate option "$name".'); 253 throw new IllegalArgumentException('Duplicate option "$name".');
254 } 254 }
255 255
256 // Make sure the abbreviation isn't too long or in use. 256 // Make sure the abbreviation isn't too long or in use.
257 if (abbr != null) { 257 if (abbr != null) {
258 if (abbr.length > 1) { 258 if (abbr.length > 1) {
259 throw new IllegalArgumentException( 259 throw new IllegalArgumentException(
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 allowedBuffer.add(allowed); 771 allowedBuffer.add(allowed);
772 if (allowed == option.defaultValue) { 772 if (allowed == option.defaultValue) {
773 allowedBuffer.add(' (default)'); 773 allowedBuffer.add(' (default)');
774 } 774 }
775 first = false; 775 first = false;
776 } 776 }
777 allowedBuffer.add(']'); 777 allowedBuffer.add(']');
778 return allowedBuffer.toString(); 778 return allowedBuffer.toString();
779 } 779 }
780 } 780 }
OLDNEW
« no previous file with comments | « no previous file | pkg/args/test/args_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698