| 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 * ## Defining options ## | 9 * ## Defining options ## |
| 10 * | 10 * |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 throw new ArgumentError('No option named $option'); | 324 throw new ArgumentError('No option named $option'); |
| 325 } | 325 } |
| 326 return options[option].defaultValue; | 326 return options[option].defaultValue; |
| 327 } | 327 } |
| 328 | 328 |
| 329 /** | 329 /** |
| 330 * Finds the option whose abbreviation is [abbr], or `null` if no option has | 330 * Finds the option whose abbreviation is [abbr], or `null` if no option has |
| 331 * that abbreviation. | 331 * that abbreviation. |
| 332 */ | 332 */ |
| 333 Option findByAbbreviation(String abbr) { | 333 Option findByAbbreviation(String abbr) { |
| 334 return options.values.firstMatching((option) => option.abbreviation == abbr, | 334 return options.values.firstWhere((option) => option.abbreviation == abbr, |
| 335 orElse: () => null); | 335 orElse: () => null); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 /** | 339 /** |
| 340 * A command-line option. Includes both flags and options which take a value. | 340 * A command-line option. Includes both flags and options which take a value. |
| 341 */ | 341 */ |
| 342 class Option { | 342 class Option { |
| 343 final String name; | 343 final String name; |
| 344 final String abbreviation; | 344 final String abbreviation; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 'Could not find an option named "$name".'); | 393 'Could not find an option named "$name".'); |
| 394 } | 394 } |
| 395 | 395 |
| 396 return _options[name]; | 396 return _options[name]; |
| 397 } | 397 } |
| 398 | 398 |
| 399 /** Get the names of the options as a [Collection]. */ | 399 /** Get the names of the options as a [Collection]. */ |
| 400 Collection<String> get options => _options.keys.toList(growable: false); | 400 Collection<String> get options => _options.keys.toList(growable: false); |
| 401 } | 401 } |
| 402 | 402 |
| OLD | NEW |