| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 operator [](String name) { | 524 operator [](String name) { |
| 525 if (!_options.containsKey(name)) { | 525 if (!_options.containsKey(name)) { |
| 526 throw new IllegalArgumentException( | 526 throw new IllegalArgumentException( |
| 527 'Could not find an option named "$name".'); | 527 'Could not find an option named "$name".'); |
| 528 } | 528 } |
| 529 | 529 |
| 530 return _options[name]; | 530 return _options[name]; |
| 531 } | 531 } |
| 532 | 532 |
| 533 /** Get the names of the options as a [Collection]. */ | 533 /** Get the names of the options as a [Collection]. */ |
| 534 Collection<String> get options => _options.getKeys(); | 534 Collection<String> get options() => _options.getKeys(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 class _Option { | 537 class _Option { |
| 538 final String name; | 538 final String name; |
| 539 final String abbreviation; | 539 final String abbreviation; |
| 540 final List allowed; | 540 final List allowed; |
| 541 final defaultValue; | 541 final defaultValue; |
| 542 final Function callback; | 542 final Function callback; |
| 543 final String help; | 543 final String help; |
| 544 final Map<String, String> allowedHelp; | 544 final Map<String, String> allowedHelp; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 allowedBuffer.add(allowed); | 763 allowedBuffer.add(allowed); |
| 764 if (allowed == option.defaultValue) { | 764 if (allowed == option.defaultValue) { |
| 765 allowedBuffer.add(' (default)'); | 765 allowedBuffer.add(' (default)'); |
| 766 } | 766 } |
| 767 first = false; | 767 first = false; |
| 768 } | 768 } |
| 769 allowedBuffer.add(']'); | 769 allowedBuffer.add(']'); |
| 770 return allowedBuffer.toString(); | 770 return allowedBuffer.toString(); |
| 771 } | 771 } |
| 772 } | 772 } |
| OLD | NEW |