App-SimulateReads
view release on metacpan or search on metacpan
lib/App/SimulateReads/CLI/App.pm view on Meta::CPAN
package App::SimulateReads::CLI::App;
# ABSTRACT: App::SimulateReads::CLI subclass for command line application interface.
use App::SimulateReads::Base 'class';
use Path::Class 'file';
use Pod::Usage;
use Try::Tiny;
extends 'App::SimulateReads::CLI';
with 'App::SimulateReads::Role::ParseArgv';
our $VERSION = '0.16'; # VERSION
has 'command_stack' => (
traits => ['Array'],
is => 'ro',
isa => 'ArrayRef[HashRef]',
default => sub { [] },
handles => {
add_command => 'push',
get_command => 'get',
map_command => 'map',
has_no_command => 'is_empty'
}
);
has 'app_path' => (
is => 'ro',
isa => 'Str',
builder => '_build_app_path'
);
sub _build_app_path {
# Determine dynamic the app path that inherit from this class
# If no one is inheriting, return this class path
my $class = (caller(1))[3];
$class =~ s/::new//;
my $command_pm = file(split /::/ => "$class.pm");
return $INC{$command_pm};
}
override 'opt_spec' => sub {
super,
'version|v'
};
sub command_map_bultin {
help => \&help_command,
man => \&man_command
}
sub command_map {
# It needs to be override
}
sub error {
my ($self, $error_msg) = @_;
my $sender = $self->_whois;
chomp $error_msg;
die "$sender: $error_msg\n";
}
sub _whois {
my $self = shift;
my $sender = $self->progname;
my @commands = $self->map_command(sub { $_->{name} });
( run in 0.593 second using v1.01-cache-2.11-cpan-39bf76dae61 )