| 1 | package App::Critique::Command::init; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 1 | our $VERSION = '0.03'; | |||||||||||
| 7 | 1 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||
| 8 | |||||||||||||
| 9 | 1 | ▶ | use App::Critique::Session; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 1 | ▶ | use App::Critique -command; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | sub opt_spec { | ||||||||||||
| 14 | 0 | ▶ | my ($class) = @_; | ||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 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 | ▶ | my ($self, $opt, $args) = @_; | ||||||||||
|
Subroutine
execute: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||
| 28 | |||||||||||||
| 29 | 0 | ▶ | if ( $opt->verbose ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 0 | info(HR_LIGHT); | |||||||||||
| 31 | 0 | info('Attempting to initialize session file using the following options:'); | |||||||||||
| 32 | 0 | info(HR_LIGHT); | |||||||||||
| 33 | 0 | ▶ | info(' --perl-critic-profile = %s', $opt->perl_critic_profile // '[...]'); | ||||||||||
|
Condition0%0/2
$opt->perl_critic_profile // "[...]"
MC/DC0%0/1
$opt->perl_critic_profile // "[...]"
$opt->perl_critic_profile
Truth table0%0/2
A
A= $opt->perl_critic_profile
| |||||||||||||
| 34 | 0 | ▶ | info(' --perl-critic-theme = %s', $opt->perl_critic_theme // '[...]'); | ||||||||||
|
Condition0%0/2
$opt->perl_critic_theme // "[...]"
MC/DC0%0/1
$opt->perl_critic_theme // "[...]"
$opt->perl_critic_theme
Truth table0%0/2
A
A= $opt->perl_critic_theme
| |||||||||||||
| 35 | 0 | ▶ | info(' --perl-critic-policy = %s', $opt->perl_critic_policy // '[...]'); | ||||||||||
|
Condition0%0/2
$opt->perl_critic_policy // "[...]"
MC/DC0%0/1
$opt->perl_critic_policy // "[...]"
$opt->perl_critic_policy
Truth table0%0/2
A
A= $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 | ▶ | if ( $opt->verbose ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 0 | info(HR_LIGHT); | |||||||||||
| 50 | 0 | info('Successuflly created session with the following configuration:'); | |||||||||||
| 51 | 0 | info(HR_LIGHT); | |||||||||||
| 52 | 0 | ▶ | info(' perl_critic_profile = %s', $session->perl_critic_profile // '[auto]'); | ||||||||||
|
Condition0%0/2
$session->perl_critic_profile // "[auto]"
MC/DC0%0/1
$session->perl_critic_profile // "[auto]"
$session->perl_critic_profile
Truth table0%0/2
A
A= $session->perl_critic_profile
| |||||||||||||
| 53 | 0 | ▶ | info(' perl_critic_theme = %s', $session->perl_critic_theme // '[auto]'); | ||||||||||
|
Condition0%0/2
$session->perl_critic_theme // "[auto]"
MC/DC0%0/1
$session->perl_critic_theme // "[auto]"
$session->perl_critic_theme
Truth table0%0/2
A
A= $session->perl_critic_theme
| |||||||||||||
| 54 | 0 | ▶ | info(' perl_critic_policy = %s', $session->perl_critic_policy // '[auto]'); | ||||||||||
|
Condition0%0/2
$session->perl_critic_policy // "[auto]"
MC/DC0%0/1
$session->perl_critic_policy // "[auto]"
$session->perl_critic_policy
Truth table0%0/2
A
A= $session->perl_critic_policy
| |||||||||||||
| 55 | 0 | ▶ | info(' git_work_tree = %s', $session->git_work_tree // '[auto]'); | ||||||||||
|
Condition0%0/2
$session->git_work_tree // "[auto]"
MC/DC0%0/1
$session->git_work_tree // "[auto]"
$session->git_work_tree
Truth table0%0/2
A
A= $session->git_work_tree
| |||||||||||||
| 56 | 0 | ▶ | info(' git_branch = %s', $session->git_branch // '[auto]'); | ||||||||||
|
Condition0%0/2
$session->git_branch // "[auto]"
MC/DC0%0/1
$session->git_branch // "[auto]"
$session->git_branch
Truth table0%0/2
A
A= $session->git_branch
| |||||||||||||
| 57 | 0 | info(HR_LIGHT); | |||||||||||
| 58 | } | ||||||||||||
| 59 | else { | ||||||||||||
| 60 | 0 | info('Successuflly created session.'); | |||||||||||
| 61 | } | ||||||||||||
| 62 | |||||||||||||
| 63 | 0 | ▶ | if ( $session->session_file_exists ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 64 | 0 | my $session_file_path = $session->session_file_path; | |||||||||||
| 65 | 0 | ▶ | if ( $opt->force ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | 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.03 | ||||||||||||
| 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 | |||||||||||||