Permalink
Browse files

simplify detection of old-style ->run usage

  • Loading branch information...
1 parent f1e3f31 commit c892020158a7a80b7fc536863e96afd0d44a5c9a @rjbs committed Aug 28, 2009
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/App/Cmd/Command.pm
View
13 lib/App/Cmd/Command.pm
@@ -86,15 +86,14 @@ warn about this behavior during testing, to remind you to fix the method name!
sub execute {
my $class = shift;
- if ($class->can('run') and $ENV{HARNESS_ACTIVE}) {
- warn "App::Cmd::Command subclasses should implement ->execute not ->run";
- }
- $class->run(@_);
-}
+ if (my $run = $class->can('run')) {
+ warn "App::Cmd::Command subclasses should implement ->execute not ->run"
+ if $ENV{HARNESS_ACTIVE};
+
+ return $class->$run(@_);
+ }
-sub run {
- my $class = shift;
Carp::croak "$class does not implement mandatory method 'execute'\n";
}

0 comments on commit c892020

Please sign in to comment.