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 ## | 9 * ## Installing ## |
10 * | 10 * |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 | 308 |
309 options[name] = new Option(name, abbr, help, allowed, allowedHelp, | 309 options[name] = new Option(name, abbr, help, allowed, allowedHelp, |
310 defaultsTo, callback, isFlag: isFlag, negatable: negatable, | 310 defaultsTo, callback, isFlag: isFlag, negatable: negatable, |
311 allowMultiple: allowMultiple); | 311 allowMultiple: allowMultiple); |
312 } | 312 } |
313 | 313 |
314 /** | 314 /** |
315 * Parses [args], a list of command-line arguments, matches them against the | 315 * Parses [args], a list of command-line arguments, matches them against the |
316 * flags and options defined by this parser, and returns the result. | 316 * flags and options defined by this parser, and returns the result. |
| 317 * |
| 318 * If [continueParsing] is set, the parser will continue parsing even after it |
| 319 * finds an argument that is not an option. This allows you to specify options |
| 320 * after your command parameters. |
317 */ | 321 */ |
318 ArgResults parse(List<String> args) => | 322 ArgResults parse(List<String> args, {bool continueParsing: false}) => |
319 new Parser(null, this, args.toList()).parse(); | 323 new Parser(null, this, args.toList(), continueParsing).parse(); |
320 | 324 |
321 /** | 325 /** |
322 * Generates a string displaying usage information for the defined options. | 326 * Generates a string displaying usage information for the defined options. |
323 * This is basically the help text shown on the command line. | 327 * This is basically the help text shown on the command line. |
324 */ | 328 */ |
325 String getUsage() => new Usage(this).generate(); | 329 String getUsage() => new Usage(this).generate(); |
326 | 330 |
327 /** | 331 /** |
328 * Get the default value for an option. Useful after parsing to test | 332 * Get the default value for an option. Useful after parsing to test |
329 * if the user specified something other than the default. | 333 * if the user specified something other than the default. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 'Could not find an option named "$name".'); | 432 'Could not find an option named "$name".'); |
429 } | 433 } |
430 | 434 |
431 return _options[name]; | 435 return _options[name]; |
432 } | 436 } |
433 | 437 |
434 /** Get the names of the options as an [Iterable]. */ | 438 /** Get the names of the options as an [Iterable]. */ |
435 Iterable<String> get options => _options.keys; | 439 Iterable<String> get options => _options.keys; |
436 } | 440 } |
437 | 441 |
OLD | NEW |