| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * This library lets you define parsers for parsing raw command-line arguments | 6 * This library lets you define parsers for parsing raw command-line arguments |
| 7 * into a set of options and values using [GNU][] and [POSIX][] style options. | 7 * into a set of options and values using [GNU][] and [POSIX][] style options. |
| 8 * | 8 * |
| 9 * ## Defining options ## | 9 * ## Defining options ## |
| 10 * | 10 * |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 _addOption(name, abbr, help, null, null, defaultsTo, callback, | 235 _addOption(name, abbr, help, null, null, defaultsTo, callback, |
| 236 isFlag: true, negatable: negatable); | 236 isFlag: true, negatable: negatable); |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * Defines a value-taking option. Throws an [ArgumentError] if: | 240 * Defines a value-taking option. Throws an [ArgumentError] if: |
| 241 * | 241 * |
| 242 * * There is already an option with name [name]. | 242 * * There is already an option with name [name]. |
| 243 * * There is already an option using abbreviation [abbr]. | 243 * * There is already an option using abbreviation [abbr]. |
| 244 */ | 244 */ |
| 245 void addOption(String name, [String abbr, String help, List<String> allowed, | 245 void addOption(String name, {String abbr, String help, List<String> allowed, |
| 246 Map<String, String> allowedHelp, String defaultsTo, | 246 Map<String, String> allowedHelp, String defaultsTo, |
| 247 void callback(value), bool allowMultiple = false]) { | 247 void callback(value), bool allowMultiple: false}) { |
| 248 _addOption(name, abbr, help, allowed, allowedHelp, defaultsTo, | 248 _addOption(name, abbr, help, allowed, allowedHelp, defaultsTo, |
| 249 callback, isFlag: false, allowMultiple: allowMultiple); | 249 callback, isFlag: false, allowMultiple: allowMultiple); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void _addOption(String name, String abbr, String help, List<String> allowed, | 252 void _addOption(String name, String abbr, String help, List<String> allowed, |
| 253 Map<String, String> allowedHelp, defaultsTo, | 253 Map<String, String> allowedHelp, defaultsTo, |
| 254 void callback(value), {bool isFlag, bool negatable: false, | 254 void callback(value), {bool isFlag, bool negatable: false, |
| 255 bool allowMultiple: false}) { | 255 bool allowMultiple: false}) { |
| 256 // Make sure the name isn't in use. | 256 // Make sure the name isn't in use. |
| 257 if (_options.containsKey(name)) { | 257 if (_options.containsKey(name)) { |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 allowedBuffer.add(allowed); | 776 allowedBuffer.add(allowed); |
| 777 if (allowed == option.defaultValue) { | 777 if (allowed == option.defaultValue) { |
| 778 allowedBuffer.add(' (default)'); | 778 allowedBuffer.add(' (default)'); |
| 779 } | 779 } |
| 780 first = false; | 780 first = false; |
| 781 } | 781 } |
| 782 allowedBuffer.add(']'); | 782 allowedBuffer.add(']'); |
| 783 return allowedBuffer.toString(); | 783 return allowedBuffer.toString(); |
| 784 } | 784 } |
| 785 } | 785 } |
| OLD | NEW |