| 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 operator [](String name) { | 537 operator [](String name) { |
| 538 if (!_options.containsKey(name)) { | 538 if (!_options.containsKey(name)) { |
| 539 throw new ArgumentError( | 539 throw new ArgumentError( |
| 540 'Could not find an option named "$name".'); | 540 'Could not find an option named "$name".'); |
| 541 } | 541 } |
| 542 | 542 |
| 543 return _options[name]; | 543 return _options[name]; |
| 544 } | 544 } |
| 545 | 545 |
| 546 /** Get the names of the options as a [Collection]. */ | 546 /** Get the names of the options as a [Collection]. */ |
| 547 Collection<String> get options => _options.keys; | 547 Collection<String> get options => _options.keys.toList(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 class _Option { | 550 class _Option { |
| 551 final String name; | 551 final String name; |
| 552 final String abbreviation; | 552 final String abbreviation; |
| 553 final List allowed; | 553 final List allowed; |
| 554 final defaultValue; | 554 final defaultValue; |
| 555 final Function callback; | 555 final Function callback; |
| 556 final String help; | 556 final String help; |
| 557 final Map<String, String> allowedHelp; | 557 final Map<String, String> allowedHelp; |
| (...skipping 218 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 |