@@ -175,6 +175,15 @@ String get usage => _parser.usage;
175
175
Configuration parse (List <String > args) => _Parser (args).parse ();
176
176
177
177
PathConfiguration _parsePathConfiguration (String option) {
178
+ var firstQuestion = option.indexOf ('?' );
179
+ if (firstQuestion == - 1 ) {
180
+ return PathConfiguration (testPath: option);
181
+ } else if (option.substring (0 , firstQuestion).contains ('\\ ' )) {
182
+ throw FormatException (
183
+ 'When passing test path queries, you must pass the path in URI '
184
+ 'format (use `/` for directory separators instead of `\\ `).' );
185
+ }
186
+
178
187
final uri = Uri .parse (option);
179
188
180
189
final names = uri.queryParametersAll['name' ];
@@ -210,8 +219,9 @@ class _Parser {
210
219
/// Returns the parsed configuration.
211
220
Configuration parse () {
212
221
var patterns = (_options['name' ] as List <String >)
213
- .map <Pattern >(
214
- (value) => _wrapFormatException ('name' , () => RegExp (value)))
222
+ .map <Pattern >((value) => _wrapFormatException (
223
+ value, () => RegExp (value),
224
+ optionName: 'name' ))
215
225
.toList ()
216
226
..addAll (_options['plain-name' ] as List <String >);
217
227
@@ -342,7 +352,8 @@ class _Parser {
342
352
var value = _options[name];
343
353
if (value == null ) return null ;
344
354
345
- return _wrapFormatException (name, () => parse (value as String ));
355
+ return _wrapFormatException (value, () => parse (value as String ),
356
+ optionName: name);
346
357
}
347
358
348
359
Map <String , String >? _parseFileReporterOption () =>
@@ -362,11 +373,13 @@ class _Parser {
362
373
363
374
/// Runs [parse] , and wraps any [FormatException] it throws with additional
364
375
/// information.
365
- T _wrapFormatException <T >(String name, T Function () parse) {
376
+ T _wrapFormatException <T >(Object ? value, T Function () parse,
377
+ {String ? optionName}) {
366
378
try {
367
379
return parse ();
368
380
} on FormatException catch (error) {
369
- throw FormatException ('Couldn\' t parse --$name "${_options [name ]}": '
381
+ throw FormatException (
382
+ 'Couldn\' t parse ${optionName == null ? '' : '--$optionName ' }"$value ": '
370
383
'${error .message }' );
371
384
}
372
385
}
0 commit comments