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

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

Issue 1748333005: Make it strong mode clean. (Closed) Base URL: https://github.com/dart-lang/args.git@master
Patch Set: Created 4 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
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 import 'arg_parser.dart'; 5 import 'arg_parser.dart';
6 import 'arg_results.dart'; 6 import 'arg_results.dart';
7 import 'option.dart'; 7 import 'option.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 17 matching lines...) Expand all
28 28
29 /// The arguments being parsed. 29 /// The arguments being parsed.
30 final List<String> args; 30 final List<String> args;
31 31
32 /// The remaining non-option, non-command arguments. 32 /// The remaining non-option, non-command arguments.
33 final rest = <String>[]; 33 final rest = <String>[];
34 34
35 /// The accumulated parsed options. 35 /// The accumulated parsed options.
36 final Map<String, dynamic> results = <String, dynamic>{}; 36 final Map<String, dynamic> results = <String, dynamic>{};
37 37
38 Parser(this.commandName, this.grammar, this.args, this.parent, rest) { 38 Parser(this.commandName, this.grammar, this.args,
39 [this.parent, List<String> rest]) {
39 if (rest != null) this.rest.addAll(rest); 40 if (rest != null) this.rest.addAll(rest);
nweiz 2016/03/02 23:58:54 This addAll thing seems weird. Maybe change to "re
Bob Nystrom 2016/03/03 00:19:08 It is a bit weird, but if I recall, it needs to co
40 } 41 }
41 42
42 /// The current argument being parsed. 43 /// The current argument being parsed.
43 String get current => args[0]; 44 String get current => args[0];
44 45
45 /// Parses the arguments. This can only be called once. 46 /// Parses the arguments. This can only be called once.
46 ArgResults parse() { 47 ArgResults parse() {
47 var arguments = args.toList(); 48 var arguments = args.toList();
48 var commandResults = null; 49 var commandResults = null;
49 50
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 279 }
279 280
280 /// Validates that [value] is allowed as a value of [option]. 281 /// Validates that [value] is allowed as a value of [option].
281 void _validateAllowed(Option option, String value) { 282 void _validateAllowed(Option option, String value) {
282 if (option.allowed == null) return; 283 if (option.allowed == null) return;
283 284
284 validate(option.allowed.contains(value), 285 validate(option.allowed.contains(value),
285 '"$value" is not an allowed value for option "${option.name}".'); 286 '"$value" is not an allowed value for option "${option.name}".');
286 } 287 }
287 } 288 }
OLDNEW
« lib/command_runner.dart ('K') | « lib/src/help_command.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698