Skip to content
This repository
Browse code

simplify detection of old-style ->run usage

  • Loading branch information...
commit c892020158a7a80b7fc536863e96afd0d44a5c9a 1 parent f1e3f31
Ricardo Signes authored

Showing 1 changed file with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. +6 7 lib/App/Cmd/Command.pm
13 lib/App/Cmd/Command.pm
@@ -86,15 +86,14 @@ warn about this behavior during testing, to remind you to fix the method name!
86 86
87 87 sub execute {
88 88 my $class = shift;
89   - if ($class->can('run') and $ENV{HARNESS_ACTIVE}) {
90   - warn "App::Cmd::Command subclasses should implement ->execute not ->run";
91   - }
92 89
93   - $class->run(@_);
94   -}
  90 + if (my $run = $class->can('run')) {
  91 + warn "App::Cmd::Command subclasses should implement ->execute not ->run"
  92 + if $ENV{HARNESS_ACTIVE};
  93 +
  94 + return $class->$run(@_);
  95 + }
95 96
96   -sub run {
97   - my $class = shift;
98 97 Carp::croak "$class does not implement mandatory method 'execute'\n";
99 98 }
100 99

0 comments on commit c892020

Please sign in to comment.
Something went wrong with that request. Please try again.