line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
3431
|
use 5.006; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package MouseX::App::Cmd::Command; |
4
|
1
|
|
|
1
|
|
4
|
use Mouse; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.30'; # VERSION |
7
|
1
|
|
|
1
|
|
761
|
use Getopt::Long::Descriptive (); |
|
1
|
|
|
|
|
22960
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
8
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
extends 'Mouse::Object', 'App::Cmd::Command'; |
10
|
|
|
|
|
|
|
with 'MouseX::Getopt'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has usage => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
metaclass => 'NoGetopt', |
16
|
|
|
|
|
|
|
isa => 'Object', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has app => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
metaclass => 'NoGetopt', |
23
|
|
|
|
|
|
|
isa => 'MouseX::App::Cmd', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
override _process_args => sub { |
27
|
|
|
|
|
|
|
my ( $class, $args ) = @_; |
28
|
|
|
|
|
|
|
local @ARGV = @{$args}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $config_from_file; |
31
|
|
|
|
|
|
|
if ( $class->meta->does_role('MouseX::ConfigFromFile') ) { |
32
|
|
|
|
|
|
|
local @ARGV = @ARGV; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $configfile; |
35
|
|
|
|
|
|
|
my $opt_parser; |
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
## no critic (Modules::RequireExplicitInclusion) |
38
|
|
|
|
|
|
|
$opt_parser |
39
|
|
|
|
|
|
|
= Getopt::Long::Parser->new( config => ['pass_through'] ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
$opt_parser->getoptions( 'configfile=s' => \$configfile ); |
42
|
|
|
|
|
|
|
if ( not defined $configfile |
43
|
|
|
|
|
|
|
and $class->can('_get_default_configfile') ) |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
$configfile = $class->_get_default_configfile(); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if ( defined $configfile ) { |
49
|
|
|
|
|
|
|
$config_from_file = $class->get_config_from_file($configfile); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my %processed = $class->_parse_argv( |
54
|
|
|
|
|
|
|
params => { argv => \@ARGV }, |
55
|
|
|
|
|
|
|
options => [ $class->_attrs_to_options($config_from_file) ], |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return ( |
59
|
|
|
|
|
|
|
$processed{params}, |
60
|
|
|
|
|
|
|
$processed{argv}, |
61
|
|
|
|
|
|
|
usage => $processed{usage}, |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# params from CLI are also fields in MouseX::Getopt |
64
|
|
|
|
|
|
|
$config_from_file |
65
|
|
|
|
|
|
|
? ( %{$config_from_file}, %{ $processed{params} } ) |
66
|
|
|
|
|
|
|
: %{ $processed{params} }, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _usage_format { ## no critic (ProhibitUnusedPrivateSubroutines) |
71
|
0
|
|
|
0
|
|
|
return shift->usage_desc; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
## no critic (Modules::RequireExplicitInclusion) |
75
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ABSTRACT: Base class for MouseX::Getopt based App::Cmd::Commands |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |