| 1 | package App::Critique::Command; | ||||||||||
| 2 | |||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 16 | our $VERSION = '0.03'; | |||||||||
| 7 | 16 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||
| 8 | |||||||||||
| 9 | 16 | ▶ | use Path::Tiny (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 16 | ▶ | use App::Cmd::Setup -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | sub opt_spec { | ||||||||||
| 14 | 0 | ▶ | my ( $class, $app ) = @_; | ||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 15 | return ( | ||||||||||
| 16 | [ 'git-work-tree=s', 'git working tree, defaults to current working directory', { default => Path::Tiny->cwd } ], | ||||||||||
| 17 | [], | ||||||||||
| 18 | [ 'verbose|v', 'display additional information', { default => $App::Critique::CONFIG{'VERBOSE'} } ], | ||||||||||
| 19 | 0 | [ 'debug|d', 'display debugging information', { default => $App::Critique::CONFIG{'DEBUG'}, implies => 'verbose' } ], | |||||||||
| 20 | ); | ||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub validate_args { | ||||||||||
| 24 | 0 | ▶ | my ($self, $opt, $args) = @_; | ||||||||
|
Subroutine
validate_args: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | $self->usage_error('The git-work-tree does not exist (' . $opt->git_work_tree . ')') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | unless -d $opt->git_work_tree; | ||||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | sub cautiously_load_session { | ||||||||||
| 31 | 0 | ▶ | my ($self, $opt, $args) = @_; | ||||||||
|
Subroutine
cautiously_load_session: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | if ( my $session_file_path = App::Critique::Session->locate_session_file( $opt->git_work_tree ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | my $session; | |||||||||
| 36 | eval { | ||||||||||
| 37 | 0 | $session = App::Critique::Session->load( $session_file_path ); | |||||||||
| 38 | 0 | 1; | |||||||||
| 39 | 0 | ▶ | } or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | my $e = "$@"; | |||||||||
| 41 | 0 | chomp $e; | |||||||||
| 42 | 0 | ▶ | if ( $opt->debug ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | my ($self, $session, $opt, $args) = @_; | ||||||||
|
Subroutine
cautiously_store_session: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 58 | |||||||||||
| 59 | 0 | my $session_file_path = $session->session_file_path; | |||||||||
| 60 | |||||||||||
| 61 | eval { | ||||||||||
| 62 | 0 | $session->store; | |||||||||
| 63 | 0 | 1; | |||||||||
| 64 | 0 | ▶ | } or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | my $e = "$@"; | |||||||||
| 66 | 0 | chomp $e; | |||||||||
| 67 | 0 | ▶ | if ( $opt->debug ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 16 | 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.03 | ||||||||||
| 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 | |||||||||||