r43212 - in /trunk/libapp-cmd-perl: ./ debian/ lib/App/ lib/App/Cmd/ lib/App/Cmd/Command/ lib/App/Cmd/Subdispatch/ t/lib/Test/ t/lib/Test/MyCmd/Command/ t/lib/Test/WSNCC/Command/ t/lib/Test/WithSetup/Command/

carnil-guest at users.alioth.debian.org carnil-guest at users.alioth.debian.org
Sat Aug 29 05:35:03 UTC 2009


Author: carnil-guest
Date: Sat Aug 29 05:34:56 2009
New Revision: 43212

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=43212
Log:
* New upstream release
  - "use MyApp -run;" is deprecated
  - Commands should use ->execute instead of ->run
  - App::Cmd::Simple programs must use ->execute rather than ->run

Added:
    trunk/libapp-cmd-perl/debian/NEWS
Modified:
    trunk/libapp-cmd-perl/Changes
    trunk/libapp-cmd-perl/META.yml
    trunk/libapp-cmd-perl/debian/changelog
    trunk/libapp-cmd-perl/lib/App/Cmd.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/ArgProcessor.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Command.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Command/commands.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Command/help.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Simple.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch/DashedStyle.pm
    trunk/libapp-cmd-perl/lib/App/Cmd/Tutorial.pod
    trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/frobulate.pm
    trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/justusage.pm
    trunk/libapp-cmd-perl/t/lib/Test/MySimple.pm
    trunk/libapp-cmd-perl/t/lib/Test/WSNCC/Command/blort.pm
    trunk/libapp-cmd-perl/t/lib/Test/WSOF.pm
    trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/alfie.pm
    trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/bertie.pm

Modified: trunk/libapp-cmd-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/Changes?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/Changes (original)
+++ trunk/libapp-cmd-perl/Changes Sat Aug 29 05:34:56 2009
@@ -1,4 +1,19 @@
 Revision history for App-Cmd
+
+0.300     2009-09-28
+          DEPRECATED -run OPTION TO APP CLASS IMPORT
+          "use MyApp -run;" is deprecated; it will be removed after no less
+          than a year
+
+          this led to problems where normal exit-on-error messages confused
+          users by complaining about failing to compile; magic to stop this is
+          not worth the tiny savings
+
+          COMMANDS SHOULD NOW HAVE ->execute RATHER THAN ->run
+          this will not break you code... except:
+
+          WILL BREAK YOUR CODE: App::Cmd::Simple programs must use ->execute
+          rather than ->run
 
 0.207     2009-09-27
           add option to allow any unambiguous command abbreviation

Modified: trunk/libapp-cmd-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/META.yml?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/META.yml (original)
+++ trunk/libapp-cmd-perl/META.yml Sat Aug 29 05:34:56 2009
@@ -29,4 +29,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://github.com/rjbs/app-cmd
-version: 0.207
+version: 0.300

Added: trunk/libapp-cmd-perl/debian/NEWS
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/debian/NEWS?rev=43212&op=file
==============================================================================
--- trunk/libapp-cmd-perl/debian/NEWS (added)
+++ trunk/libapp-cmd-perl/debian/NEWS Sat Aug 29 05:34:56 2009
@@ -1,0 +1,20 @@
+libapp-cmd-perl (0.300-1) UNRELEASED; urgency=low
+
+  From upstream Changelog we read the following changes
+  which may break your code:
+
+          DEPRECATED -run OPTION TO APP CLASS IMPORT
+          "use MyApp -run;" is deprecated; it will be removed after no less
+          than a year
+
+          this led to problems where normal exit-on-error messages confused
+          users by complaining about failing to compile; magic to stop this is
+          not worth the tiny savings
+
+          COMMANDS SHOULD NOW HAVE ->execute RATHER THAN ->run
+          this will not break you code... except:
+
+          WILL BREAK YOUR CODE: App::Cmd::Simple programs must use ->execute
+          rather than ->run
+
+ -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>  Sat, 29 Aug 2009 07:30:58 +0200

Modified: trunk/libapp-cmd-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/debian/changelog?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/debian/changelog (original)
+++ trunk/libapp-cmd-perl/debian/changelog Sat Aug 29 05:34:56 2009
@@ -1,3 +1,12 @@
+libapp-cmd-perl (0.300-1) UNRELEASED; urgency=low
+
+  * New upstream release
+    - "use MyApp -run;" is deprecated
+    - Commands should use ->execute instead of ->run
+    - App::Cmd::Simple programs must use ->execute rather than ->run
+
+ -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>  Sat, 29 Aug 2009 07:28:03 +0200
+
 libapp-cmd-perl (0.207-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libapp-cmd-perl/lib/App/Cmd.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd.pm Sat Aug 29 05:34:56 2009
@@ -13,7 +13,10 @@
 use Sub::Exporter -setup => {
   collectors => {
     -command => \'_setup_command',
-    -run     => sub { $_[1]->{class}->run; 1 },
+    -run     => sub {
+      warn "using -run to run your command is deprecated\n";
+      $_[1]->{class}->run; 1
+    },
   },
 };
 
@@ -48,11 +51,11 @@
 
 =head1 VERSION
 
-version 0.207
-
-=cut
-
-our $VERSION = '0.207';
+version 0.300
+
+=cut
+
+our $VERSION = '0.300';
 
 =head1 SYNOPSIS
 
@@ -369,7 +372,7 @@
   local our $active_cmd = $cmd;
 
   $cmd->validate_args($opt, \@args);
-  $cmd->run($opt, \@args);
+  $cmd->execute($opt, \@args);
 }
 
 =head2 plugin_search_path

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/ArgProcessor.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/ArgProcessor.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/ArgProcessor.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/ArgProcessor.pm Sat Aug 29 05:34:56 2009
@@ -9,11 +9,11 @@
 
 =head1 VERSION
 
-version 0.207
+version 0.300
 
 =cut
 
-our $VERSION = '0.207';
+our $VERSION = '0.300';
 
 sub _process_args {
   my ($class, $args, @params) = @_;

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Command.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Command.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Command.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Command.pm Sat Aug 29 05:34:56 2009
@@ -11,11 +11,11 @@
 
 =head1 VERSION
 
-version 0.207
-
-=cut
-
-our $VERSION = '0.207';
+version 0.300
+
+=cut
+
+our $VERSION = '0.300';
 
 use Carp ();
 
@@ -69,19 +69,32 @@
   bless $arg => $class;
 }
 
-=head2 run
-
-  $command_plugin->run(\%opt, \@args);
+=head2 execute
+
+=for Pod::Coverage run
+
+  $command_plugin->execute(\%opt, \@args);
 
 This method does whatever it is the command should do!  It is passed a hash
 reference of the parsed command-line options and an array reference of left
 over arguments.
 
-=cut
-
-sub run {
-  my ($class) = @_;
-  Carp::croak "$class does not implement mandatory method 'run'\n";
+If no C<execute> method is defined, it will try to call C<run> -- but it will
+warn about this behavior during testing, to remind you to fix the method name!
+
+=cut
+
+sub execute {
+  my $class = shift;
+
+  if (my $run = $class->can('run')) {
+    warn "App::Cmd::Command subclasses should implement ->execute not ->run"
+      if $ENV{HARNESS_ACTIVE};
+
+    return $class->$run(@_);
+  }
+
+  Carp::croak "$class does not implement mandatory method 'execute'\n";
 }
 
 =head2 app

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Command/commands.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Command/commands.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Command/commands.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Command/commands.pm Sat Aug 29 05:34:56 2009
@@ -11,11 +11,11 @@
 
 =head1 VERSION
 
-version 0.207
+version 0.300
 
 =cut
 
-our $VERSION = 0.207;
+our $VERSION = 0.300;
 
 =head1 DESCRIPTION
 
@@ -24,7 +24,7 @@
 
 =head1 METHODS
 
-=head2 C<run>
+=head2 execute
 
 This is the command's primary method and raison d'etre.  It prints the
 application's usage text (if any) followed by a sorted listing of the
@@ -35,7 +35,7 @@
 
 =cut
 
-sub run {
+sub execute {
   my ($self) = @_;
 
   local $@;

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Command/help.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Command/help.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Command/help.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Command/help.pm Sat Aug 29 05:34:56 2009
@@ -11,11 +11,11 @@
 
 =head1 VERSION
 
-version 0.207
+version 0.300
 
 =cut
 
-our $VERSION = '0.207';
+our $VERSION = '0.300';
 
 =head1 DESCRIPTION
 

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Simple.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Simple.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Simple.pm Sat Aug 29 05:34:56 2009
@@ -5,7 +5,7 @@
 use App::Cmd::Command;
 BEGIN { our @ISA = 'App::Cmd::Command' }
 
-our $VERSION = '0.207';
+our $VERSION = '0.300';
 
 use App::Cmd;
 use Sub::Install;
@@ -105,8 +105,14 @@
   # This signals that something has already set the target up.
   return $class if $class->_cmd_pkg;
 
+  my $core_execute = App::Cmd::Command->can('execute');
+  my $our_execute  = $class->can('execute');
+  Carp::confess(
+    "App::Cmd::Simple subclasses must implement ->execute, not ->run"
+  ) unless $our_execute and $our_execute != $core_execute;
+
   # I doubt the $i will ever be needed, but let's start paranoid.
-  my $generated_name = join('::', $class, 'Cmd', $i++);
+  my $generated_name = join('::', $class, '_App_Cmd', $i++);
 
   {
     no strict 'refs';
@@ -117,12 +123,6 @@
     into => $class,
     as   => '_cmd_pkg',
     code => sub { $generated_name },
-  });
-
-  Sub::Install::reinstall_sub({
-    into => $class,
-    as   => "__$i", # cheap trick -- rjbs, 2007-10-09
-    code => $class->can('run'),
   });
 
   Sub::Install::install_sub({
@@ -147,19 +147,16 @@
     },
   });
 
-  # required to make compilation packages correct for caller
-  eval qq[
-    no warnings 'redefine';
-    package $class;
-    sub run {
-      my \$caller = caller;
-      return shift->__$i(\@_) if \$caller eq 'App::Cmd';
-      return ${generated_name}->new({
+  Sub::Install::install_sub({
+    into => $class,
+    as   => 'run',
+    code => sub {
+      $generated_name->new({
         no_help_plugin     => 1,
         no_commands_plugin => 1,
-      })->run(\@_);
+      })->run(@_);
     }
-  ];
+  });
 
   return $class;
 }

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch.pm Sat Aug 29 05:34:56 2009
@@ -13,11 +13,11 @@
 
 =head1 VERSION
 
-version 0.207
+version 0.300
 
 =cut
 
-our $VERSION = '0.207';
+our $VERSION = '0.300';
 
 =head1 METHODS
 

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch/DashedStyle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch/DashedStyle.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch/DashedStyle.pm (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Subdispatch/DashedStyle.pm Sat Aug 29 05:34:56 2009
@@ -11,11 +11,11 @@
 
 =head1 VERSION
 
-version 0.207
+version 0.300
 
 =cut
 
-our $VERSION = '0.207';
+our $VERSION = '0.300';
 
 =head1 METHODS
 

Modified: trunk/libapp-cmd-perl/lib/App/Cmd/Tutorial.pod
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/lib/App/Cmd/Tutorial.pod?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/lib/App/Cmd/Tutorial.pod (original)
+++ trunk/libapp-cmd-perl/lib/App/Cmd/Tutorial.pod Sat Aug 29 05:34:56 2009
@@ -17,7 +17,8 @@
 generally consist of just a few lines:
 
   #!/usr/bin/perl
-  use YourApp -run;
+  use YourApp;
+  YourApp->run;
 
 All the work of argument parsing, validation, and dispatch is taken care of by
 your application class.  The application class can also be pretty simple, and
@@ -52,9 +53,9 @@
   YourApp::Command::initialize does not implement mandatory method 'run'
 
 Oops!  This dies because we haven't told the command class what it should do
-when run.  This is easy, we just add some code:
+when executed.  This is easy, we just add some code:
 
-  sub run {
+  sub execute {
     my ($self, $opt, $args) = @_;
 
     print "Everything has been initialized.  (Not really.)\n";

Modified: trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/frobulate.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/frobulate.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/frobulate.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/frobulate.pm Sat Aug 29 05:34:56 2009
@@ -16,7 +16,7 @@
   );
 }
 
-sub run {
+sub execute {
   my ($self, $opt, $arg) =@_;
 
   die "the widget name is $opt->{widget} - @$arg\n";

Modified: trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/justusage.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/justusage.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/justusage.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/MyCmd/Command/justusage.pm Sat Aug 29 05:34:56 2009
@@ -11,7 +11,7 @@
 
 =cut
 
-sub run {
+sub execute {
   my ($self, $opt, $arg) = @_;
 
   die $self->usage->text;

Modified: trunk/libapp-cmd-perl/t/lib/Test/MySimple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/MySimple.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/MySimple.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/MySimple.pm Sat Aug 29 05:34:56 2009
@@ -5,7 +5,7 @@
 
 use Data::Dumper;
 
-sub run {
+sub execute {
   my ($self, $opt, $args) = @_;
 
   local $Data::Dumper::Terse = 1;

Modified: trunk/libapp-cmd-perl/t/lib/Test/WSNCC/Command/blort.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/WSNCC/Command/blort.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/WSNCC/Command/blort.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/WSNCC/Command/blort.pm Sat Aug 29 05:34:56 2009
@@ -3,7 +3,7 @@
 package Test::WSNCC::Command::blort;
 use Test::WSNCC -command;
 
-sub run {
+sub execute {
   my ($self, $opt, $args) = @_;
   return $opt;
 }

Modified: trunk/libapp-cmd-perl/t/lib/Test/WSOF.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/WSOF.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/WSOF.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/WSOF.pm Sat Aug 29 05:34:56 2009
@@ -10,6 +10,6 @@
 package Test::WSOF::Command::poot;
 use Test::WSOF -command;
 
-sub run { return 'woof woof poot' }
+sub execute { return 'woof woof poot' }
 
 1;

Modified: trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/alfie.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/alfie.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/alfie.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/alfie.pm Sat Aug 29 05:34:56 2009
@@ -3,7 +3,7 @@
 package Test::WithSetup::Command::alfie;
 use Test::WithSetup -command;
 
-sub run {
+sub execute {
   my ($self, $opt, $args) = @_;
   return $opt;
 }

Modified: trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/bertie.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/bertie.pm?rev=43212&op=diff
==============================================================================
--- trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/bertie.pm (original)
+++ trunk/libapp-cmd-perl/t/lib/Test/WithSetup/Command/bertie.pm Sat Aug 29 05:34:56 2009
@@ -3,7 +3,7 @@
 package Test::WithSetup::Command::bertie;
 use Test::WithSetup -command;
 
-sub run {
+sub execute {
   my ($self, $opt, $args) = @_;
   return xyzzy foo => 'bar';
 }




More information about the Pkg-perl-cvs-commits mailing list