| 1 | package Module::Format::PerlMF_App; | ||||||||||||||||||||||||||||||||
| 2 | 2 | $Module::Format::PerlMF_App::VERSION = '0.4.0'; | |||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Module::Format::ModuleList; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | sub new | ||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 14 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||
| 15 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||
| 16 | 0 | $self->_init(@_); | |||||||||||||||||||||||||||||||
| 17 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | sub _argv | ||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_argv: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||
| 26 | 0 | $self->{_argv} = shift; | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 0 | return $self->{_argv}; | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | sub _init | ||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 34 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 0 | $self->_argv( [ @{ $args->{argv} } ] ); | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 0 | return; | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 2 | my %ops_to_formats = ( | |||||||||||||||||||||||||||||||
| 43 | 'as_rpm_colon' => 'rpm_colon', | ||||||||||||||||||||||||||||||||
| 44 | 'rpm_colon' => 'rpm_colon', | ||||||||||||||||||||||||||||||||
| 45 | 'as_rpm_c' => 'rpm_colon', | ||||||||||||||||||||||||||||||||
| 46 | 'rpm_c' => 'rpm_colon', | ||||||||||||||||||||||||||||||||
| 47 | 'as_rpm_dash' => 'rpm_dash', | ||||||||||||||||||||||||||||||||
| 48 | 'rpm_dash' => 'rpm_dash', | ||||||||||||||||||||||||||||||||
| 49 | 'as_rpm_d' => 'rpm_dash', | ||||||||||||||||||||||||||||||||
| 50 | 'rpm_d' => 'rpm_dash', | ||||||||||||||||||||||||||||||||
| 51 | 'dash' => 'dash', | ||||||||||||||||||||||||||||||||
| 52 | 'as_dash' => 'dash', | ||||||||||||||||||||||||||||||||
| 53 | 'colon' => 'colon', | ||||||||||||||||||||||||||||||||
| 54 | 'as_colon' => 'colon', | ||||||||||||||||||||||||||||||||
| 55 | 'deb' => 'debian', | ||||||||||||||||||||||||||||||||
| 56 | 'as_deb' => 'debian', | ||||||||||||||||||||||||||||||||
| 57 | 'debian' => 'debian', | ||||||||||||||||||||||||||||||||
| 58 | 'as_debian' => 'debian', | ||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | sub run | ||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 63 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | my $argv = $self->_argv(); | |||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 0 | my $op = shift(@$argv); | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( !defined($op) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||
| 71 | 0 | die "You did not specify any arguments - see --help"; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( ( $op eq "-h" ) || ( $op eq "--help" ) ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$op eq "-h" or $op eq "--help"
MC/DC0%0/2
$op eq "-h" or $op eq "--help"
$op eq "-h"
$op eq "--help"
Truth table0%0/3
A or B
A= $op eq "-h"B= $op eq "--help"
| |||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||
| 76 | 0 | pod2usage(1); | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | elsif ( $op eq "--man" ) | ||||||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||||||
| 80 | 0 | pod2usage( -verbose => 2 ); | |||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ( !exists( $ops_to_formats{$op} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||
| 85 | 0 | die "Unknown op '$op'."; | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 0 | my $format = $ops_to_formats{$op}; | |||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 0 | my $delim = ' '; | |||||||||||||||||||||||||||||||
| 91 | 0 | my $suffix = "\n"; | |||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 0 | my $help = 0; | |||||||||||||||||||||||||||||||
| 94 | 0 | my $man = 0; | |||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | !( | ||||||||||||||||||||||||||||||||
| 97 | my $ret = GetOptionsFromArray( | ||||||||||||||||||||||||||||||||
| 98 | $argv, | ||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | '0!' => sub { $delim = "\0"; $suffix = q{}; }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | 'n!' => sub { $delim = "\n"; $suffix = "\n"; }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 101 | 'help|h' => \$help, | ||||||||||||||||||||||||||||||||
| 102 | man => \$man, | ||||||||||||||||||||||||||||||||
| 103 | ) | ||||||||||||||||||||||||||||||||
| 104 | ) | ||||||||||||||||||||||||||||||||
| 105 | ) | ||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||
| 107 | 0 | die "GetOptions failed!"; | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($help) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||
| 112 | 0 | pod2usage(1); | |||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($man) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||
| 117 | 0 | pod2usage( -verbose => 2 ); | |||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | 0 | my @strings = @$argv; | |||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 0 | my $module_list_obj = Module::Format::ModuleList->sane_from_guesses( | |||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||
| 124 | values => \@strings, | ||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | 0 | print join( $delim, @{ $module_list_obj->format_as($format) } ), $suffix; | |||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 0 | return; | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 2 | 1; # End of Module::Format::PerlMF_App | |||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | __END__ | ||||||||||||||||||||||||||||||||