App::CLI::Extension::Component::InstallCallback - for App::CLI::Extension install callback module
1.421
# 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 . . .
App::CLI::Extension Class::Accessor::Grouped
Akira Horimoto
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
To install App::CLI::Extension, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::CLI::Extension
CPAN shell
perl -MCPAN -e shell install App::CLI::Extension
For more information on module installation, please visit the detailed CPAN module installation guide.