Chromium Code Reviews| 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 * And then run `pub install`. | |
|
Andrei Mouravski
2013/04/19 20:13:35
You're starting a sentence with "and" but it's upp
sethladd
2013/04/19 20:32:43
The reference to pub below is just to make the lin
| |
| 18 * | |
| 9 * ## Defining options ## | 19 * ## Defining options ## |
| 10 * | 20 * |
| 11 * To use this library, you create an [ArgParser] object which will contain | 21 * To use this library, you create an [ArgParser] object which will contain |
| 12 * the set of options you support: | 22 * the set of options you support: |
| 13 * | 23 * |
| 14 * var parser = new ArgParser(); | 24 * var parser = new ArgParser(); |
| 15 * | 25 * |
| 16 * Then you define a set of options on that parser using [addOption()] and | 26 * Then you define a set of options on that parser using [addOption()] and |
| 17 * [addFlag()]. The minimal way to create an option is: | 27 * [addFlag()]. The minimal way to create an option is: |
| 18 * | 28 * |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 * [arm] ARM Holding 32-bit chip | 212 * [arm] ARM Holding 32-bit chip |
| 203 * [ia32] Intel x86 | 213 * [ia32] Intel x86 |
| 204 * | 214 * |
| 205 * To assist the formatting of the usage help, single line help text will | 215 * 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 | 216 * 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 | 217 * will be followed by two new lines. This provides spatial diversity between |
| 208 * options. | 218 * options. |
| 209 * | 219 * |
| 210 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h tml#tag_12_02 | 220 * [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 | 221 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte rfaces |
| 222 * [pub]: http://pub.dartlang.org | |
| 212 */ | 223 */ |
| 213 library args; | 224 library args; |
| 214 | 225 |
| 215 import 'src/parser.dart'; | 226 import 'src/parser.dart'; |
| 216 import 'src/usage.dart'; | 227 import 'src/usage.dart'; |
| 217 | 228 |
| 218 /** | 229 /** |
| 219 * A class for taking a list of raw command line arguments and parsing out | 230 * A class for taking a list of raw command line arguments and parsing out |
| 220 * options and flags from them. | 231 * options and flags from them. |
| 221 */ | 232 */ |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 'Could not find an option named "$name".'); | 425 'Could not find an option named "$name".'); |
| 415 } | 426 } |
| 416 | 427 |
| 417 return _options[name]; | 428 return _options[name]; |
| 418 } | 429 } |
| 419 | 430 |
| 420 /** Get the names of the options as an [Iterable]. */ | 431 /** Get the names of the options as an [Iterable]. */ |
| 421 Iterable<String> get options => _options.keys; | 432 Iterable<String> get options => _options.keys; |
| 422 } | 433 } |
| 423 | 434 |
| OLD | NEW |