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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 * [arm] ARM Holding 32-bit chip | 175 * [arm] ARM Holding 32-bit chip |
176 * [ia32] Intel x86 | 176 * [ia32] Intel x86 |
177 * | 177 * |
178 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h
tml#tag_12_02 | 178 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h
tml#tag_12_02 |
179 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte
rfaces | 179 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte
rfaces |
180 */ | 180 */ |
181 #library('args'); | 181 #library('args'); |
182 | 182 |
183 #import('dart:math'); | 183 #import('dart:math'); |
184 | 184 |
185 #import('utils.dart'); | 185 // TODO(rnystrom): Use "package:" URL here when test.dart can handle pub. |
| 186 #import('src/utils.dart'); |
186 | 187 |
187 /** | 188 /** |
188 * A class for taking a list of raw command line arguments and parsing out | 189 * A class for taking a list of raw command line arguments and parsing out |
189 * options and flags from them. | 190 * options and flags from them. |
190 */ | 191 */ |
191 class ArgParser { | 192 class ArgParser { |
192 static const _SOLO_OPT = const RegExp(@'^-([a-zA-Z0-9])$'); | 193 static const _SOLO_OPT = const RegExp(@'^-([a-zA-Z0-9])$'); |
193 static const _ABBR_OPT = const RegExp(@'^-([a-zA-Z0-9]+)(.*)$'); | 194 static const _ABBR_OPT = const RegExp(@'^-([a-zA-Z0-9]+)(.*)$'); |
194 static const _LONG_OPT = const RegExp(@'^--([a-zA-Z\-_0-9]+)(=(.*))?$'); | 195 static const _LONG_OPT = const RegExp(@'^--([a-zA-Z\-_0-9]+)(=(.*))?$'); |
195 | 196 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 allowedBuffer.add(allowed); | 766 allowedBuffer.add(allowed); |
766 if (allowed == option.defaultValue) { | 767 if (allowed == option.defaultValue) { |
767 allowedBuffer.add(' (default)'); | 768 allowedBuffer.add(' (default)'); |
768 } | 769 } |
769 first = false; | 770 first = false; |
770 } | 771 } |
771 allowedBuffer.add(']'); | 772 allowedBuffer.add(']'); |
772 return allowedBuffer.toString(); | 773 return allowedBuffer.toString(); |
773 } | 774 } |
774 } | 775 } |
OLD | NEW |