OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * ## Installing ## |
| 10 * |
| 11 * Use [pub][] to install this package. Add the following to your `pubspec.yaml` |
| 12 * file. |
| 13 * |
| 14 * dependencies: |
| 15 * args: any |
| 16 * |
| 17 * Then run `pub install`. |
| 18 * |
| 19 * For more information, see the |
| 20 * [args package on pub.dartlang.org](http://pub.dartlang.org/packages/args). |
| 21 * |
9 * ## Defining options ## | 22 * ## Defining options ## |
10 * | 23 * |
11 * To use this library, you create an [ArgParser] object which will contain | 24 * To use this library, you create an [ArgParser] object which will contain |
12 * the set of options you support: | 25 * the set of options you support: |
13 * | 26 * |
14 * var parser = new ArgParser(); | 27 * var parser = new ArgParser(); |
15 * | 28 * |
16 * Then you define a set of options on that parser using [addOption()] and | 29 * Then you define a set of options on that parser using [addOption()] and |
17 * [addFlag()]. The minimal way to create an option is: | 30 * [addFlag()]. The minimal way to create an option is: |
18 * | 31 * |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 * [arm] ARM Holding 32-bit chip | 215 * [arm] ARM Holding 32-bit chip |
203 * [ia32] Intel x86 | 216 * [ia32] Intel x86 |
204 * | 217 * |
205 * To assist the formatting of the usage help, single line help text will | 218 * To assist the formatting of the usage help, single line help text will |
206 * be followed by a single new line. Options with multi-line help text | 219 * be followed by a single new line. Options with multi-line help text |
207 * will be followed by two new lines. This provides spatial diversity between | 220 * will be followed by two new lines. This provides spatial diversity between |
208 * options. | 221 * options. |
209 * | 222 * |
210 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h
tml#tag_12_02 | 223 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h
tml#tag_12_02 |
211 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte
rfaces | 224 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte
rfaces |
| 225 * [pub]: http://pub.dartlang.org |
212 */ | 226 */ |
213 library args; | 227 library args; |
214 | 228 |
215 import 'src/parser.dart'; | 229 import 'src/parser.dart'; |
216 import 'src/usage.dart'; | 230 import 'src/usage.dart'; |
217 | 231 |
218 /** | 232 /** |
219 * A class for taking a list of raw command line arguments and parsing out | 233 * A class for taking a list of raw command line arguments and parsing out |
220 * options and flags from them. | 234 * options and flags from them. |
221 */ | 235 */ |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 'Could not find an option named "$name".'); | 428 'Could not find an option named "$name".'); |
415 } | 429 } |
416 | 430 |
417 return _options[name]; | 431 return _options[name]; |
418 } | 432 } |
419 | 433 |
420 /** Get the names of the options as an [Iterable]. */ | 434 /** Get the names of the options as an [Iterable]. */ |
421 Iterable<String> get options => _options.keys; | 435 Iterable<String> get options => _options.keys; |
422 } | 436 } |
423 | 437 |
OLD | NEW |