From: Tomas Doran Date: Thu, 19 Nov 2009 22:48:04 +0000 (+0000) Subject: Pull exiting with useage out into a method X-Git-Tag: 0.25~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8df55e62a4d1278fab4366b2516ecc673820a1f6;p=gitmo%2FMooseX-Getopt.git Pull exiting with useage out into a method --- diff --git a/lib/MooseX/Getopt/Basic.pm b/lib/MooseX/Getopt/Basic.pm index 453b913..5000746 100644 --- a/lib/MooseX/Getopt/Basic.pm +++ b/lib/MooseX/Getopt/Basic.pm @@ -55,7 +55,7 @@ sub new_with_options { } my $constructor_params = ( @params == 1 ? $params[0] : {@params} ); - + Carp::croak("Single parameters to new_with_options() must be a HASH ref") unless ref($constructor_params) eq 'HASH'; @@ -71,7 +71,7 @@ sub new_with_options { # did the user request usage information? if ( $processed{usage} && ($params->{'?'} or $params->{help} or $params->{usage}) ) { - $processed{usage}->die(); + $class->_exit_with_usage($processed{usage}); } $class->new( @@ -82,6 +82,11 @@ sub new_with_options { ); } +sub _exit_with_usage { + my ($self, $usage) = @_; + $usage->die(); +} + sub _parse_argv { my ( $class, %params ) = @_;