Chromium Code Reviews| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 } | 232 } |
| 233 | 233 |
| 234 /** | 234 /** |
| 235 * Defines a value-taking option. Throws an [IllegalArgumentException] if: | 235 * Defines a value-taking option. Throws an [IllegalArgumentException] if: |
| 236 * | 236 * |
| 237 * * There is already an option with name [name]. | 237 * * There is already an option with name [name]. |
| 238 * * There is already an option using abbreviation [abbr]. | 238 * * There is already an option using abbreviation [abbr]. |
| 239 */ | 239 */ |
| 240 void addOption(String name, [String abbr, String help, List<String> allowed, | 240 void addOption(String name, [String abbr, String help, List<String> allowed, |
| 241 Map<String, String> allowedHelp, String defaultsTo, | 241 Map<String, String> allowedHelp, String defaultsTo, |
| 242 void callback(bool value), bool allowMultiple = false]) { | 242 void callback(Dynamic value), bool allowMultiple = false]) { |
|
Bob Nystrom
2012/09/18 00:43:25
I don't know if the style guide mentions this (it
butlermatt
2012/09/18 13:13:50
Done.
| |
| 243 _addOption(name, abbr, help, allowed, allowedHelp, defaultsTo, | 243 _addOption(name, abbr, help, allowed, allowedHelp, defaultsTo, |
| 244 callback, isFlag: false, allowMultiple: allowMultiple); | 244 callback, isFlag: false, allowMultiple: allowMultiple); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void _addOption(String name, String abbr, String help, List<String> allowed, | 247 void _addOption(String name, String abbr, String help, List<String> allowed, |
| 248 Map<String, String> allowedHelp, defaultsTo, | 248 Map<String, String> allowedHelp, defaultsTo, |
| 249 void callback(bool value), [bool isFlag, bool negatable = false, | 249 void callback(Dynamic value), [bool isFlag, bool negatable = false, |
|
Bob Nystrom
2012/09/18 00:43:25
And here.
butlermatt
2012/09/18 13:13:50
Done.
| |
| 250 bool allowMultiple = false]) { | 250 bool allowMultiple = false]) { |
| 251 // Make sure the name isn't in use. | 251 // Make sure the name isn't in use. |
| 252 if (_options.containsKey(name)) { | 252 if (_options.containsKey(name)) { |
| 253 throw new IllegalArgumentException('Duplicate option "$name".'); | 253 throw new IllegalArgumentException('Duplicate option "$name".'); |
| 254 } | 254 } |
| 255 | 255 |
| 256 // Make sure the abbreviation isn't too long or in use. | 256 // Make sure the abbreviation isn't too long or in use. |
| 257 if (abbr != null) { | 257 if (abbr != null) { |
| 258 if (abbr.length > 1) { | 258 if (abbr.length > 1) { |
| 259 throw new IllegalArgumentException( | 259 throw new IllegalArgumentException( |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 allowedBuffer.add(allowed); | 771 allowedBuffer.add(allowed); |
| 772 if (allowed == option.defaultValue) { | 772 if (allowed == option.defaultValue) { |
| 773 allowedBuffer.add(' (default)'); | 773 allowedBuffer.add(' (default)'); |
| 774 } | 774 } |
| 775 first = false; | 775 first = false; |
| 776 } | 776 } |
| 777 allowedBuffer.add(']'); | 777 allowedBuffer.add(']'); |
| 778 return allowedBuffer.toString(); | 778 return allowedBuffer.toString(); |
| 779 } | 779 } |
| 780 } | 780 } |
| OLD | NEW |