The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::CLI::Extension::Component::InstallCallback - for App::CLI::Extension install callback module

VERSION

1.421

SYNOPSIS

  # MyApp.pm
  package MyApp;
  
  use strict;
  use base qw(App::CLI::Extension);
  
  # MyApp/Hello.pm
  package MyApp::Hello;
  use strict;
  use feature ":5.10.0";
  use base qw(App::CLI::Command);
  use constants options => ("runmode=s" => "runmode");
   
  sub prerun {
  
      my($self, @argv) = @_;
          $self->new_callback("view", sub {
                                   my($self, @args) = @_;
                                                                   # anything view to do...
                                   foreach $list (@{$self->anything_all_list}) {
                                       printf "%d: %s\n", $list->id, $list->name;
                                                                   }
                               });
          $self->new_callback("exec", sub {
                                   my($self, @args) = @_;
                                                                   # anything execute to do...
                                                                   $self->anything_execute(@args);
                               });
      $self->>maybe::next::method(@argv);
  }
  
  sub run {
  
      my($self, @args) = @_;
      my $runmode = $self->{runmode};
      if ($self->exists_callback($runmode)) {
          $self->exec_callback($runmode, @args);
      } else {
          die "invalid runmode!!";
          }
  }
  
  # myapp
  #!/usr/bin/perl
  
  use strict;
  use MyApp;
  
  MyApp->dispatch;
  
  # execute view callback
  [kurt@localhost ~] myapp hello --runmode=view
  1: melon
  2: banana
     .
     .
     .

SEE ALSO

App::CLI::Extension Class::Accessor::Grouped

AUTHOR

Akira Horimoto

COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Copyright (C) 2010 Akira Horimoto