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

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

Issue 363083002: Allow defining a help string for an option's parameter value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
OLDNEW
1 library options; 1 library options;
2 2
3 import 'package:collection/wrappers.dart'; 3 import 'package:collection/wrappers.dart';
4 4
5 /// A command-line option. Includes both flags and options which take a value. 5 /// A command-line option. Includes both flags and options which take a value.
6 class Option { 6 class Option {
7 final String name; 7 final String name;
8 final String abbreviation; 8 final String abbreviation;
9 final List<String> allowed; 9 final List<String> allowed;
10 final defaultValue; 10 final defaultValue;
11 final Function callback; 11 final Function callback;
12 final String help; 12 final String help;
13 final String valueHelp;
13 final Map<String, String> allowedHelp; 14 final Map<String, String> allowedHelp;
14 final bool isFlag; 15 final bool isFlag;
15 final bool negatable; 16 final bool negatable;
16 final bool allowMultiple; 17 final bool allowMultiple;
17 final bool hide; 18 final bool hide;
18 19
19 Option(this.name, this.abbreviation, this.help, List<String> allowed, 20 Option(this.name, this.abbreviation, this.help, this.valueHelp,
20 Map<String, String> allowedHelp, this.defaultValue, this.callback, 21 List<String> allowed, Map<String, String> allowedHelp, this.defaultValue,
21 {this.isFlag, this.negatable, this.allowMultiple: false, 22 this.callback, {this.isFlag, this.negatable, this.allowMultiple: false,
22 this.hide: false}) : 23 this.hide: false}) :
23 this.allowed = allowed == null ? 24 this.allowed = allowed == null ?
24 null : new UnmodifiableListView(allowed), 25 null : new UnmodifiableListView(allowed),
25 this.allowedHelp = allowedHelp == null ? 26 this.allowedHelp = allowedHelp == null ?
26 null : new UnmodifiableMapView(allowedHelp) { 27 null : new UnmodifiableMapView(allowedHelp) {
27 28
28 if (name.isEmpty) { 29 if (name.isEmpty) {
29 throw new ArgumentError('Name cannot be empty.'); 30 throw new ArgumentError('Name cannot be empty.');
30 } else if (name.startsWith('-')) { 31 } else if (name.startsWith('-')) {
31 throw new ArgumentError('Name $name cannot start with "-".'); 32 throw new ArgumentError('Name $name cannot start with "-".');
(...skipping 12 matching lines...) Expand all
44 } 45 }
45 46
46 if (_invalidChars.hasMatch(abbreviation)) { 47 if (_invalidChars.hasMatch(abbreviation)) {
47 throw new ArgumentError('Abbreviation is an invalid character.'); 48 throw new ArgumentError('Abbreviation is an invalid character.');
48 } 49 }
49 } 50 }
50 } 51 }
51 52
52 static final _invalidChars = new RegExp(r'''[ \t\r\n"'\\/]'''); 53 static final _invalidChars = new RegExp(r'''[ \t\r\n"'\\/]''');
53 } 54 }
OLDNEW
« pkg/args/README.md ('K') | « pkg/args/lib/args.dart ('k') | pkg/args/lib/src/usage.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698