From: Rafael Garcia-Suarez Date: Sun, 4 Nov 2007 19:48:32 +0000 (+0000) Subject: Update Term::UI to 0.18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e7718d1e334a834bb11f7976318d1993cc7feb9;p=p5sagit%2Fp5-mst-13.2.git Update Term::UI to 0.18 p4raw-id: //depot/perl@32220 --- diff --git a/lib/Term/UI.pm b/lib/Term/UI.pm index c7cd4cd..4b20faa 100644 --- a/lib/Term/UI.pm +++ b/lib/Term/UI.pm @@ -11,7 +11,7 @@ use strict; BEGIN { use vars qw[$VERSION $AUTOREPLY $VERBOSE $INVALID]; $VERBOSE = 1; - $VERSION = '0.16'; + $VERSION = '0.18'; $INVALID = loc('Invalid selection, please try again: '); } @@ -404,9 +404,9 @@ sub parse_options { 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; diff --git a/lib/Term/UI/t/02_ui.t b/lib/Term/UI/t/02_ui.t index 874ffc8..6e0b34a 100644 --- a/lib/Term/UI/t/02_ui.t +++ b/lib/Term/UI/t/02_ui.t @@ -2,7 +2,7 @@ use strict; use lib qw[../lib lib]; -use Test::More tests => 13; +use Test::More tests => 19; use Term::ReadLine; use_ok( 'Term::UI' ); @@ -124,3 +124,21 @@ my $tmpl = { 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" ); + } +}