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

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

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

Powered by Google App Engine
This is Rietveld 408576698