| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Critique::Command::init; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1189
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use App::Critique::Session; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
3
|
use App::Critique -command; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub opt_spec { |
|
14
|
0
|
|
|
0
|
1
|
|
my ($class) = @_; |
|
15
|
|
|
|
|
|
|
return ( |
|
16
|
0
|
|
|
|
|
|
[ 'perl-critic-profile=s', 'path to a Perl::Critic profile to use (default let Perl::Critic decide)' ], |
|
17
|
|
|
|
|
|
|
[ 'perl-critic-theme=s', 'Perl::Critic theme expression to use' ], |
|
18
|
|
|
|
|
|
|
[ 'perl-critic-policy=s', 'singular Perl::Critic policy to use (overrides -theme and -policy)' ], |
|
19
|
|
|
|
|
|
|
[], |
|
20
|
|
|
|
|
|
|
[ 'force', 'force overwriting of existing session file' ], |
|
21
|
|
|
|
|
|
|
[], |
|
22
|
|
|
|
|
|
|
$class->SUPER::opt_spec, |
|
23
|
|
|
|
|
|
|
) |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub execute { |
|
27
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if ( $opt->verbose ) { |
|
30
|
0
|
|
|
|
|
|
info(HR_LIGHT); |
|
31
|
0
|
|
|
|
|
|
info('Attempting to initialize session file using the following options:'); |
|
32
|
0
|
|
|
|
|
|
info(HR_LIGHT); |
|
33
|
0
|
|
0
|
|
|
|
info(' --perl-critic-profile = %s', $opt->perl_critic_profile // '[...]'); |
|
34
|
0
|
|
0
|
|
|
|
info(' --perl-critic-theme = %s', $opt->perl_critic_theme // '[...]'); |
|
35
|
0
|
|
0
|
|
|
|
info(' --perl-critic-policy = %s', $opt->perl_critic_policy // '[...]'); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
else { |
|
38
|
0
|
|
|
|
|
|
info('Attempting to initialize session file ...'); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $session = App::Critique::Session->new( |
|
42
|
|
|
|
|
|
|
perl_critic_profile => $opt->perl_critic_profile, |
|
43
|
|
|
|
|
|
|
perl_critic_theme => $opt->perl_critic_theme, |
|
44
|
|
|
|
|
|
|
perl_critic_policy => $opt->perl_critic_policy, |
|
45
|
|
|
|
|
|
|
git_work_tree => $opt->git_work_tree, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ( $opt->verbose ) { |
|
49
|
0
|
|
|
|
|
|
info(HR_LIGHT); |
|
50
|
0
|
|
|
|
|
|
info('Successuflly created session with the following configuration:'); |
|
51
|
0
|
|
|
|
|
|
info(HR_LIGHT); |
|
52
|
0
|
|
0
|
|
|
|
info(' perl_critic_profile = %s', $session->perl_critic_profile // '[auto]'); |
|
53
|
0
|
|
0
|
|
|
|
info(' perl_critic_theme = %s', $session->perl_critic_theme // '[auto]'); |
|
54
|
0
|
|
0
|
|
|
|
info(' perl_critic_policy = %s', $session->perl_critic_policy // '[auto]'); |
|
55
|
0
|
|
0
|
|
|
|
info(' git_work_tree = %s', $session->git_work_tree // '[auto]'); |
|
56
|
0
|
|
0
|
|
|
|
info(' git_branch = %s', $session->git_branch // '[auto]'); |
|
57
|
0
|
|
|
|
|
|
info(HR_LIGHT); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else { |
|
60
|
0
|
|
|
|
|
|
info('Successuflly created session.'); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ( $session->session_file_exists ) { |
|
64
|
0
|
|
|
|
|
|
my $session_file_path = $session->session_file_path; |
|
65
|
0
|
0
|
|
|
|
|
if ( $opt->force ) { |
|
66
|
0
|
|
|
|
|
|
warning('Overwriting session file (%s) with --force option.', $session_file_path); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else { |
|
69
|
0
|
|
|
|
|
|
error( |
|
70
|
|
|
|
|
|
|
'Unable to overwrite session file (%s) without --force option.', |
|
71
|
|
|
|
|
|
|
$session_file_path |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->cautiously_store_session( $session, $opt, $args ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
info('Session file (%s) initialized successfully.', $session->session_file_path); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
App::Critique::Command::init - Initialize critique session file |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
version 0.04 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This command will create a critique session file in your F<~/.critique> |
|
96
|
|
|
|
|
|
|
directory (including creating the F<~/.critique> directory if needed). |
|
97
|
|
|
|
|
|
|
This file will be used to store information about the critque session, |
|
98
|
|
|
|
|
|
|
such as the set of files you wish to critique and your progress in |
|
99
|
|
|
|
|
|
|
processing the set. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The specific file path for the critique session will be based on the |
|
102
|
|
|
|
|
|
|
information provided through the command line options, and will look |
|
103
|
|
|
|
|
|
|
something like this: |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
~/.critique/<git-repo>/<git-branch>/session.json |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The value of C<git-repo> will be surmised from the C<git-work-tree> |
|
108
|
|
|
|
|
|
|
which itself defaults to finding the root of the C<git> working directory |
|
109
|
|
|
|
|
|
|
via your current working directory. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The value of C<git-branch> comes directly from the command line option, |
|
112
|
|
|
|
|
|
|
or will default itself to the currently active C<git> branch. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
You must also supply L<Perl::Critic> informaton must be specified, either |
|
115
|
|
|
|
|
|
|
as a L<Perl::Critic> profile config (ex: F<perlcriticrc>) with additional |
|
116
|
|
|
|
|
|
|
L<Perl::Critic> 'theme' expression added. Alternatively you can just |
|
117
|
|
|
|
|
|
|
specify a single L<Perl::Critic::Policy> to use during the critique |
|
118
|
|
|
|
|
|
|
session. If no L<Perl::Critic> specific options are detected, then we will |
|
119
|
|
|
|
|
|
|
do whatever is the default for L<Perl::Critic>, which currently is to |
|
120
|
|
|
|
|
|
|
use all the available policies with their default configuration. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Stevan Little. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
131
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# ABSTRACT: Initialize critique session file |
|
138
|
|
|
|
|
|
|
|