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

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

Issue 12316155: Make arg parser return growable list of rest arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | utils/pub/pub.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library args.src.parser; 5 library args.src.parser;
6 6
7 import '../args.dart'; 7 import '../args.dart';
8 8
9 final _SOLO_OPT = new RegExp(r'^-([a-zA-Z0-9])$'); 9 final _SOLO_OPT = new RegExp(r'^-([a-zA-Z0-9])$');
10 final _ABBR_OPT = new RegExp(r'^-([a-zA-Z0-9]+)(.*)$'); 10 final _ABBR_OPT = new RegExp(r'^-([a-zA-Z0-9]+)(.*)$');
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 grammar.options.forEach((name, option) { 88 grammar.options.forEach((name, option) {
89 if (option.allowMultiple && 89 if (option.allowMultiple &&
90 results[name].length == 0 && 90 results[name].length == 0 &&
91 option.defaultValue != null) { 91 option.defaultValue != null) {
92 results[name].add(option.defaultValue); 92 results[name].add(option.defaultValue);
93 } 93 }
94 if (option.callback != null) option.callback(results[name]); 94 if (option.callback != null) option.callback(results[name]);
95 }); 95 });
96 96
97 // Add in the leftover arguments we didn't parse to the innermost command. 97 // Add in the leftover arguments we didn't parse to the innermost command.
98 var rest = args.toList(); 98 var rest = args.toList(growable: true);
99 args.clear(); 99 args.clear();
100 return new ArgResults(results, commandName, commandResults, rest); 100 return new ArgResults(results, commandName, commandResults, rest);
101 } 101 }
102 102
103 /** 103 /**
104 * Pulls the value for [option] from the second argument in [args]. Validates 104 * Pulls the value for [option] from the second argument in [args]. Validates
105 * that there is a valid value there. 105 * that there is a valid value there.
106 */ 106 */
107 void readNextArgAsValue(Option option) { 107 void readNextArgAsValue(Option option) {
108 // Take the option argument from the next command line arg. 108 // Take the option argument from the next command line arg.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 '"$value" is not an allowed value for option "${option.name}".'); 272 '"$value" is not an allowed value for option "${option.name}".');
273 } 273 }
274 274
275 if (option.allowMultiple) { 275 if (option.allowMultiple) {
276 results[option.name].add(value); 276 results[option.name].add(value);
277 } else { 277 } else {
278 results[option.name] = value; 278 results[option.name] = value;
279 } 279 }
280 } 280 }
281 } 281 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698