X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FApp%2FRgit%2FCommand.pm;h=fa98b6ec20c8662a8d60d066bf2477b0b24cf7a6;hb=5b2d059b23a0c56067d68d072a4df7b638ac94c3;hp=c43cc6c5c9e7cbe21a3a4622acd5e8c6b2163bbd;hpb=76ba389e3711e8f254aea83f9b3b7b221c0517a8;p=perl%2Fmodules%2Frgit.git diff --git a/lib/App/Rgit/Command.pm b/lib/App/Rgit/Command.pm index c43cc6c..fa98b6e 100644 --- a/lib/App/Rgit/Command.pm +++ b/lib/App/Rgit/Command.pm @@ -3,9 +3,9 @@ package App::Rgit::Command; use strict; use warnings; -use Carp qw/croak/; +use Carp (); -use App::Rgit::Utils qw/validate :codes/; +use App::Rgit::Utils qw/:codes/; =head1 NAME @@ -37,17 +37,25 @@ my %commands; __PACKAGE__->action($_ => 'Once') for qw/daemon gui help init version/, ' '; sub new { - my ($class, %args) = &validate; + my $class = shift; + $class = ref $class || $class; + + my %args = @_; + my $cmd = $args{cmd}; $cmd = ' ' unless defined $cmd; + my $action = $class->action($cmd); + if ($class eq __PACKAGE__) { $class = $action; } else { - croak "Command $cmd should be executed as a $action" - unless $class->isa($action); + Carp::confess("Command $cmd should be executed as a $action") + unless $class->isa($action); } - eval "require $action; 1" or croak "Couldn't load $action: $@"; + + eval "require $action; 1" or Carp::confess("Couldn't load $action: $@"); + bless { cmd => $cmd, args => $args{args} || [ ], @@ -118,7 +126,7 @@ L. =head1 AUTHOR Vincent Pit, C<< >>, L. - + You can contact me by mail or on C (vincent). =head1 BUGS