Analizo/Command.pm

filter: Statementstmt 64.1% 25 / 39 Branchbran 25.0% 3 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 33.3% 1 / 3 totaltotal 58.7% 37 / 63 CC 7 SCAR 24.1
CC
7
Cov
55%
show_manpage
30.0
validate_args
3.2
BEGIN
1.0
CRAP 11.1
« Analizo/Extractor/Doxyparse.pm ↑ Summary Analizo/Command/tree_evolution.pm »
1 package Analizo::Command;
2 18 ▶use App::Cmd::Setup -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Class::Inspector;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use Env::Path qw( PATH );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use File::Temp qw( tmpnam );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 Analizo::Command - global options for tools
12  
13 =head1 DESCRIPTION
14  
15 Following the instructions from the L<App::Cmd::Tutorial> we create this module
16 to be a superclass of every analizo tool, in that way we can have global
17 options to every analizo tool:
18  
19 analizo <tool> --help
20 analizo <tool> --usage
21  
22 Any analizo tool should implement B<validate()>, method which is called by
23 B<validate_args()> implemented here. See L<App::Cmd::Command> for details about
24 B<validate_args()>.
25  
26 =cut
27  
28 2 ▶sub validate_args {
Subroutine validate_args: called CC=3 SCAR=11.8
Pod documented
29 2 my ($self, $opt, $args) = @_;
30 2 ▶ if ($self->app->global_options->version) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->app->global_options->version) { } 1 1 2
elsif ($self->app->global_options->usage) { } 0 1 1
31 1 $self->usage_error("Invalid option: --version");
32 }
33 elsif ($self->app->global_options->usage) {
34 0 print $self->app->usage, "\n", $self->usage;
35 0 exit 0;
36 }
37 1 $self->validate($opt, $args);
38 }
39  
40 1 ▶sub version_information {
Subroutine version_information: called CC=1 SCAR=0.0
Pod undocumented
41 1 my ($self) = @_;
42 1 sprintf("%s version %s", $self->app->arg0, $Analizo::VERSION);
43 }
44  
45 0 ▶sub show_manpage {
Subroutine show_manpage: not called CC=5 SCAR=34.0
Pod undocumented
46 0 my ($self, $package, $command_name) = @_;
47 0 my $version_information = $self->version_information;
48 0 my $file = Class::Inspector->resolved_filename($package);
49 0 ▶ if (scalar PATH->Whence('man')) {
Branch: 3 branches
BranchTrueFalseTotal
if (scalar 'PATH'->Whence('man')) { } 0 0 0
elsif (scalar 'PATH'->Whence('less')) { } 0 0 0
elsif (scalar 'PATH'->Whence('more')) { } 0 0 0
50 0 my $pod2man = "pod2man --name='analizo-$command_name' --release='$version_information' --center='Analizo documentation'";
51 0 ▶ if ($^O eq 'freebsd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'freebsd') { } 0 0 0
52 0 my $tmpfile = tmpnam();
53 0 exec("$pod2man '$file' > $tmpfile && man $tmpfile && rm -f $tmpfile");
54 }
55 else {
56 0 exec("$pod2man '$file' | man -l -");
57 }
58 }
59 elsif (scalar PATH->Whence('less')) {
60 0 exec("pod2text '$file' | less");
61 }
62 elsif (scalar PATH->Whence('more')) {
63 0 exec("pod2text '$file' | more");
64 }
65 else {
66 0 exec("pod2text '$file'");
67 }
68 }
69  
70 18 1;
71  
72 =head1 COPYRIGHT AND AUTHORS
73  
74 See B<analizo(1)>.
75  
76 =cut
« Analizo/Extractor/Doxyparse.pm ↑ Summary Analizo/Command/tree_evolution.pm »