line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Critique::Command; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2452
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
105
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
151
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1334
|
use Path::Tiny (); |
|
3
|
|
|
|
|
16157
|
|
|
3
|
|
|
|
|
153
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
29
|
use App::Cmd::Setup -command; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
30
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub opt_spec { |
14
|
0
|
|
|
0
|
1
|
|
my ( $class, $app ) = @_; |
15
|
|
|
|
|
|
|
return ( |
16
|
|
|
|
|
|
|
[ 'git-work-tree=s', 'git working tree, defaults to current working directory', { default => Path::Tiny->cwd } ], |
17
|
|
|
|
|
|
|
[], |
18
|
|
|
|
|
|
|
[ 'debug|d', 'display debugging information', { default => $App::Critique::CONFIG{'DEBUG'}, implies => 'verbose' } ], |
19
|
0
|
|
|
|
|
|
[ 'verbose|v', 'display additional information', { default => $App::Critique::CONFIG{'VERBOSE'} } ], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub validate_args { |
24
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
$self->usage_error('The git-work-tree does not exist (' . $opt->git_work_tree . ')') |
27
|
|
|
|
|
|
|
unless -d $opt->git_work_tree; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub cautiously_load_session { |
31
|
0
|
|
|
0
|
0
|
|
my ($self, $opt, $args) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if ( my $session_file_path = App::Critique::Session->locate_session_file( $opt->git_work_tree ) ) { |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $session; |
36
|
|
|
|
|
|
|
eval { |
37
|
0
|
|
|
|
|
|
$session = App::Critique::Session->load( $session_file_path ); |
38
|
0
|
|
|
|
|
|
1; |
39
|
0
|
0
|
|
|
|
|
} or do { |
40
|
0
|
|
|
|
|
|
my $e = "$@"; |
41
|
0
|
|
|
|
|
|
chomp $e; |
42
|
0
|
0
|
|
|
|
|
if ( $opt->debug ) { |
43
|
0
|
|
|
|
|
|
App::Critique::Plugin::UI::_error("Unable to load session file (%s), because:\n %s", $session_file_path, $e); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
0
|
|
|
|
|
|
App::Critique::Plugin::UI::_error('Unable to load session file (%s), run with --debug|d for more information', $session_file_path); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $session; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
error('No session file found, perhaps you forgot to call `init`.'); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub cautiously_store_session { |
57
|
0
|
|
|
0
|
0
|
|
my ($self, $session, $opt, $args) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $session_file_path = $session->session_file_path; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
eval { |
62
|
0
|
|
|
|
|
|
$session->store; |
63
|
0
|
|
|
|
|
|
1; |
64
|
0
|
0
|
|
|
|
|
} or do { |
65
|
0
|
|
|
|
|
|
my $e = "$@"; |
66
|
0
|
|
|
|
|
|
chomp $e; |
67
|
0
|
0
|
|
|
|
|
if ( $opt->debug ) { |
68
|
0
|
|
|
|
|
|
App::Critique::Plugin::UI::_error("Unable to store session file (%s), because:\n %s", $session_file_path, $e); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
|
App::Critique::Plugin::UI::_error('Unable to store session file (%s), run with --debug|d for more information', $session_file_path); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return $session_file_path; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
App::Critique::Command - Command base class for App::Critique |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 0.05 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Stevan Little. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
99
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# ABSTRACT: Command base class for App::Critique |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|