App-CLI-Extension
view release on metacpan or search on metacpan
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script name is " . $self->argv0;
}
1;
# execute
[kurt@localhost ~] myapp hello
my script name is myapp
=head2 full_argv0
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script full name is " . $self->full_argv0;
}
1;
# execute
[kurt@localhost ~] myapp hello
my script name is /home/kurt/myapp
=head2 cmdline
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script cmdline is [" . $self->cmdline . "]";
}
1;
# execute
[kurt@localhost ~] myapp hello --verbose --num=10
my script cmdline is [/home/kurt/myapp hello --verbose --num=10]
=head2 orig_argv
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script original argv is [" join(", ", @{$self->orig_argv}) . "]";
}
1;
# execute
[kurt@localhost ~] myapp hello --verbose --num=10
my script original argv is [hello,--verbose, --num=10]
=head2 stash
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
$self->stash->{name} = "kurt";
say "stash value: " . $self->stash->{name};
}
1;
=head2 new_callback
install new callback phase
Example:
$self->new_callback("some_phase");
# registered callback argument pattern
$self->new_callback("some_phase", sub { $self = shift; "anything to do..." });
=head2 add_callback
install callback
Example:
$self->add_callback("some_phase", sub { my $self = shift; say "some_phase method No.1" });
$self->add_callback("some_phase", sub { my $self = shift; say "some_phase method No.1" });
$self->add_callback("any_phase", sub {
my($self, @args) = @_;
say "any_phase args: @args";
});
=cut
=head2 exec_callback
execute callback
Example:
lib/App/CLI/Extension.pm view on Meta::CPAN
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script name is " . $self->argv0;
}
1;
# execute
[kurt@localhost ~] myapp hello
my script name is myapp
=head2 full_argv0
lib/App/CLI/Extension.pm view on Meta::CPAN
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script full name is " . $self->full_argv0;
}
1;
# execute
[kurt@localhost ~] myapp hello
my script name is /home/kurt/myapp
=head2 cmdline
lib/App/CLI/Extension.pm view on Meta::CPAN
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script cmdline is [" . $self->cmdline . "]";
}
1;
# execute
[kurt@localhost ~] myapp hello --verbose --num=10
my script cmdline is [/home/kurt/myapp hello --verbose --num=10]
=head2 orig_argv
lib/App/CLI/Extension.pm view on Meta::CPAN
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
say "my script original argv is [" join(", ", @{$self->orig_argv}) . "]";
}
1;
# execute
[kurt@localhost ~] myapp hello --verbose --num=10
my script original argv is [hello,--verbose, --num=10]
=head2 stash
lib/App/CLI/Extension.pm view on Meta::CPAN
# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);
sub run {
my($self, @args) = @_;
$self->stash->{name} = "kurt";
say "stash value: " . $self->stash->{name};
}
1;
=head2 new_callback
install new callback phase
Example:
$self->new_callback("some_phase");
# registered callback argument pattern
$self->new_callback("some_phase", sub { $self = shift; "anything to do..." });
=head2 add_callback
install callback
Example:
$self->add_callback("some_phase", sub { my $self = shift; say "some_phase method No.1" });
$self->add_callback("some_phase", sub { my $self = shift; say "some_phase method No.1" });
$self->add_callback("any_phase", sub {
my($self, @args) = @_;
say "any_phase args: @args";
});
=cut
=head2 exec_callback
execute callback
Example:
( run in 2.181 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )