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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 * [ia32] Intel x86 | 181 * [ia32] Intel x86 |
182 * | 182 * |
183 * To assist the formatting of the usage help, single line help text will | 183 * To assist the formatting of the usage help, single line help text will |
184 * be followed by a single new line. Options with multi-line help text | 184 * be followed by a single new line. Options with multi-line help text |
185 * will be followed by two new lines. This provides spatial diversity between | 185 * will be followed by two new lines. This provides spatial diversity between |
186 * options. | 186 * options. |
187 * | 187 * |
188 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h
tml#tag_12_02 | 188 * [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.h
tml#tag_12_02 |
189 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte
rfaces | 189 * [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Inte
rfaces |
190 */ | 190 */ |
191 #library('args'); | 191 library args; |
192 | 192 |
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 const _SOLO_OPT = const RegExp(r'^-([a-zA-Z0-9])$'); | 203 static const _SOLO_OPT = const RegExp(r'^-([a-zA-Z0-9])$'); |
204 static const _ABBR_OPT = const RegExp(r'^-([a-zA-Z0-9]+)(.*)$'); | 204 static const _ABBR_OPT = const RegExp(r'^-([a-zA-Z0-9]+)(.*)$'); |
205 static const _LONG_OPT = const RegExp(r'^--([a-zA-Z\-_0-9]+)(=(.*))?$'); | 205 static const _LONG_OPT = const RegExp(r'^--([a-zA-Z\-_0-9]+)(=(.*))?$'); |
206 | 206 |
(...skipping 569 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 |