Index: lib/src/option.dart |
diff --git a/lib/src/option.dart b/lib/src/option.dart |
index 4045bce1e0b528b7d857631d75b1bbd38cdd49a8..07e87f68196b553490a7649ebd8a41c28b99274a 100644 |
--- a/lib/src/option.dart |
+++ b/lib/src/option.dart |
@@ -13,9 +13,10 @@ import 'dart:collection'; |
Option newOption(String name, String abbreviation, String help, |
String valueHelp, List<String> allowed, Map<String, String> allowedHelp, |
defaultValue, Function callback, OptionType type, |
- {bool negatable, bool hide: false}) { |
+ {bool negatable, bool splitCommas, bool hide: false}) { |
return new Option._(name, abbreviation, help, valueHelp, allowed, allowedHelp, |
- defaultValue, callback, type, negatable: negatable, hide: hide); |
+ defaultValue, callback, type, negatable: negatable, |
+ splitCommas: splitCommas, hide: hide); |
} |
/// A command-line option. Includes both flags and options which take a value. |
@@ -30,6 +31,7 @@ class Option { |
final Map<String, String> allowedHelp; |
final OptionType type; |
final bool negatable; |
+ final bool splitCommas; |
final bool hide; |
/// Whether the option is boolean-valued flag. |
@@ -43,13 +45,20 @@ class Option { |
Option._(this.name, this.abbreviation, this.help, this.valueHelp, |
List<String> allowed, Map<String, String> allowedHelp, this.defaultValue, |
- this.callback, this.type, {this.negatable, this.hide: false}) |
+ this.callback, OptionType type, {this.negatable, bool splitCommas, |
+ this.hide: false}) |
: this.allowed = allowed == null |
? null |
: new UnmodifiableListView(allowed), |
this.allowedHelp = allowedHelp == null |
? null |
- : new UnmodifiableMapView(allowedHelp) { |
+ : new UnmodifiableMapView(allowedHelp), |
+ this.type = type, |
+ // If the user doesn't specify [splitCommas], it defaults to true for |
+ // multiple options. |
+ this.splitCommas = splitCommas == null |
+ ? type == OptionType.MULTIPLE |
+ : splitCommas { |
if (name.isEmpty) { |
throw new ArgumentError('Name cannot be empty.'); |
} else if (name.startsWith('-')) { |