X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=blobdiff_plain;f=lib%2FApp%2FRgit%2FCommand.pm;h=348b8c40aab70ef4c659ba8167ca287222b95807;hp=3a34822317dc3a37c2b5c738528f53bd96b57d5a;hb=1c5bf56c6f80e4cd818c341b34ba3410f34ed514;hpb=caf4ff14ac06ea364ea51f725d041fd715e9682f diff --git a/lib/App/Rgit/Command.pm b/lib/App/Rgit/Command.pm index 3a34822..348b8c4 100644 --- a/lib/App/Rgit/Command.pm +++ b/lib/App/Rgit/Command.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; -use App::Rgit::Utils qw/validate :codes/; +use App::Rgit::Utils qw/:codes/; =head1 NAME @@ -37,16 +37,23 @@ 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); } + eval "require $action; 1" or croak "Couldn't load $action: $@"; bless { cmd => $cmd,