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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 import 'dart:math'; | 193 import 'dart:math'; |
194 | 194 |
195 // TODO(rnystrom): Use "package:" URL here when test.dart can handle pub. | 195 // TODO(rnystrom): Use "package:" URL here when test.dart can handle pub. |
196 import 'src/utils.dart'; | 196 import 'src/utils.dart'; |
197 | 197 |
198 /** | 198 /** |
199 * A class for taking a list of raw command line arguments and parsing out | 199 * A class for taking a list of raw command line arguments and parsing out |
200 * options and flags from them. | 200 * options and flags from them. |
201 */ | 201 */ |
202 class ArgParser { | 202 class ArgParser { |
203 static final _SOLO_OPT = new RegExp(r'^-([a-zA-Z0-9])$'); | 203 static const _SOLO_OPT = const RegExp(r'^-([a-zA-Z0-9])$'); |
204 static final _ABBR_OPT = new RegExp(r'^-([a-zA-Z0-9]+)(.*)$'); | 204 static const _ABBR_OPT = const RegExp(r'^-([a-zA-Z0-9]+)(.*)$'); |
205 static final _LONG_OPT = new RegExp(r'^--([a-zA-Z\-_0-9]+)(=(.*))?$'); | 205 static const _LONG_OPT = const RegExp(r'^--([a-zA-Z\-_0-9]+)(=(.*))?$'); |
206 | 206 |
207 final Map<String, _Option> _options; | 207 final Map<String, _Option> _options; |
208 | 208 |
209 /** | 209 /** |
210 * The names of the options, in the order that they were added. This way we | 210 * The names of the options, in the order that they were added. This way we |
211 * can generate usage information in the same order. | 211 * can generate usage information in the same order. |
212 */ | 212 */ |
213 // TODO(rnystrom): Use an ordered map type, if one appears. | 213 // TODO(rnystrom): Use an ordered map type, if one appears. |
214 final List<String> _optionNames; | 214 final List<String> _optionNames; |
215 | 215 |
(...skipping 560 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 |