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