BEGIN {
use vars qw[$VERSION $AUTOREPLY $VERBOSE $INVALID];
$VERBOSE = 1;
- $VERSION = '0.16';
+ $VERSION = '0.18';
$INVALID = loc('Invalid selection, please try again: ');
}
my $return = {};
### there's probably a more elegant way to do this... ###
- while ( $input =~ s/(?:\s+)--?([-\w]+=("|').+?\2)(?=\Z|\s+)// or
- $input =~ s/(?:\s+)--?([-\w]+=\S+)(?=\Z|\s+)// or
- $input =~ s/(?:\s+)--?([-\w]+)(?=\Z|\s+)//
+ while ( $input =~ s/(?:^|\s+)--?([-\w]+=("|').+?\2)(?=\Z|\s+)// or
+ $input =~ s/(?:^|\s+)--?([-\w]+=\S+)(?=\Z|\s+)// or
+ $input =~ s/(?:^|\s+)--?([-\w]+)(?=\Z|\s+)//
) {
my $match = $1;
use strict;
use lib qw[../lib lib];
-use Test::More tests => 13;
+use Test::More tests => 19;
use Term::ReadLine;
use_ok( 'Term::UI' );
is_deeply($href, $expected, qq[Parsing options] );
is($rest, $munged, qq[Remaining unparsed string '$munged'] );
}
+
+### more parse_options tests
+{ my @map = (
+ [ 'x --update_source' => 'x', { update_source => 1 } ],
+ [ '--update_source' => '', { update_source => 1 } ],
+ );
+
+ for my $aref ( @map ) {
+ my( $input, $munged, $expect ) = @$aref;
+
+ my($href,$rest) = $term->parse_options( $input );
+
+ ok( $href, "Parsed '$input'" );
+ is_deeply( $href, $expect,
+ " Options parsed correctly" );
+ is( $rest, $munged, " Command parsed correctly" );
+ }
+}