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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
558 final bool isFlag; | 558 final bool isFlag; |
559 final bool negatable; | 559 final bool negatable; |
560 final bool allowMultiple; | 560 final bool allowMultiple; |
561 | 561 |
562 _Option(this.name, this.abbreviation, this.help, this.allowed, | 562 _Option(this.name, this.abbreviation, this.help, this.allowed, |
563 this.allowedHelp, this.defaultValue, this.callback, [this.isFlag, | 563 this.allowedHelp, this.defaultValue, this.callback, {this.isFlag, |
564 this.negatable, this.allowMultiple = false]); | 564 this.negatable, this.allowMultiple: false}); |
565 } | 565 } |
566 | 566 |
567 /** | 567 /** |
568 * Takes an [ArgParser] and generates a string of usage (i.e. help) text for its | 568 * Takes an [ArgParser] and generates a string of usage (i.e. help) text for its |
569 * defined options. Internally, it works like a tabular printer. The output is | 569 * defined options. Internally, it works like a tabular printer. The output is |
570 * divided into three horizontal columns, like so: | 570 * divided into three horizontal columns, like so: |
571 * | 571 * |
572 * -h, --help Prints the usage information | 572 * -h, --help Prints the usage information |
573 * | | | | | 573 * | | | | |
574 * | 574 * |
(...skipping 201 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 |