MouseX-App-Cmd
view release on metacpan or search on metacpan
lib/MouseX/App/Cmd/Command.pm view on Meta::CPAN
use 5.006;
package MouseX::App::Cmd::Command;
use Mouse;
our $VERSION = '0.30'; # VERSION
use Getopt::Long::Descriptive ();
use namespace::autoclean;
extends 'Mouse::Object', 'App::Cmd::Command';
with 'MouseX::Getopt';
has usage => (
is => 'ro',
required => 1,
metaclass => 'NoGetopt',
isa => 'Object',
);
has app => (
is => 'ro',
required => 1,
metaclass => 'NoGetopt',
isa => 'MouseX::App::Cmd',
);
override _process_args => sub {
my ( $class, $args ) = @_;
local @ARGV = @{$args};
my $config_from_file;
if ( $class->meta->does_role('MouseX::ConfigFromFile') ) {
local @ARGV = @ARGV;
my $configfile;
my $opt_parser;
{
## no critic (Modules::RequireExplicitInclusion)
$opt_parser
= Getopt::Long::Parser->new( config => ['pass_through'] );
}
$opt_parser->getoptions( 'configfile=s' => \$configfile );
if ( not defined $configfile
and $class->can('_get_default_configfile') )
{
$configfile = $class->_get_default_configfile();
}
if ( defined $configfile ) {
$config_from_file = $class->get_config_from_file($configfile);
}
}
my %processed = $class->_parse_argv(
params => { argv => \@ARGV },
options => [ $class->_attrs_to_options($config_from_file) ],
);
return (
$processed{params},
$processed{argv},
usage => $processed{usage},
# params from CLI are also fields in MouseX::Getopt
$config_from_file
? ( %{$config_from_file}, %{ $processed{params} } )
: %{ $processed{params} },
);
};
sub _usage_format { ## no critic (ProhibitUnusedPrivateSubroutines)
return shift->usage_desc;
}
## no critic (Modules::RequireExplicitInclusion)
__PACKAGE__->meta->make_immutable();
1;
# ABSTRACT: Base class for MouseX::Getopt based App::Cmd::Commands
__END__
=pod
=encoding UTF-8
=for :stopwords ×××× ×§××'×× (Yuval Kogman) Infinity Interactive, Inc.
=head1 NAME
MouseX::App::Cmd::Command - Base class for MouseX::Getopt based App::Cmd::Commands
=head1 VERSION
( run in 0.556 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )