File Coverage

blib/lib/Giblog/Command/all.pm
Criterion Covered Total %
statement 21 51 41.1
branch 0 16 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 29 76 38.1


line stmt bran cond sub pod time code
1             package Giblog::Command::all;
2              
3 1     1   1116 use base 'Giblog::Command';
  1         3  
  1         116  
4              
5 1     1   7 use strict;
  1         2  
  1         21  
6 1     1   5 use warnings;
  1         2  
  1         25  
7 1     1   5 use Mojolicious;
  1         2  
  1         7  
8 1     1   45 use Time::Piece 'localtime';
  1         3  
  1         9  
9 1     1   91 use Getopt::Long 'GetOptions';
  1         3  
  1         7  
10              
11 1     1   143 use Carp 'confess';
  1         2  
  1         443  
12              
13             sub run {
14 0     0 1   my ($self, @argv) = @_;
15            
16 0           my $message;
17             my $has_no_build_option;
18 0           my $has_no_save_option;
19 0           my $has_no_publish_option;
20 0           my $has_no_deploy_option;
21             {
22 0           local @ARGV = @argv;
  0            
23 0           my $getopt_option_all = Getopt::Long::Configure(qw(default no_auto_abbrev no_ignore_case));
24 0           GetOptions(
25             'm=s' => \$message,
26             'no-build' => \$has_no_build_option,
27             'no-save' => \$has_no_save_option,
28             'no-publish' => \$has_no_publish_option,
29             'no-deploy' => \$has_no_deploy_option,
30             );
31 0           Getopt::Long::Configure($getopt_option_all);
32 0           @argv = @ARGV;
33             }
34 0           my ($remote_rep, $branch) = @argv;
35            
36 0           my $api = $self->api;
37              
38 0           my $home_dir = $api->rel_file('.');
39            
40 0 0         unless ($has_no_build_option) {
41 0           my @giblog_build_command = ('giblog', '-C', $home_dir, 'build');
42 0 0         if (system(@giblog_build_command) == -1) {
43 0           confess "Fail giblog all command. Command is @giblog_build_command: $?";
44             }
45             }
46            
47 0 0         unless ($has_no_save_option) {
48 0           my @giblog_save_command = ('giblog', '-C', $home_dir, 'save', '-m', $message, $remote_rep, $branch);
49 0 0         if(system(@giblog_save_command) == -1) {
50 0           confess "Fail giblog all command. Command is @giblog_save_command : $?";
51             }
52             }
53            
54 0 0         unless ($has_no_publish_option) {
55 0           my @giblog_publish_command = ('giblog', '-C', $home_dir, 'publish', $remote_rep, $branch);
56 0 0         if (system(@giblog_publish_command) == -1) {
57 0           confess "Fail giblog all command. Command is @giblog_publish_command : $?";
58             }
59             }
60              
61 0 0         unless ($has_no_deploy_option) {
62 0           my @giblog_deploy_command = ('giblog', '-C', $home_dir, 'deploy');
63 0 0         if (system(@giblog_deploy_command) == -1) {
64 0           confess "Fail giblog all command. Command is @giblog_deploy_command: $?";
65             }
66             }
67             }
68              
69             1;
70              
71             =encoding utf8
72              
73             =head1 NAME
74              
75             Giblog::Command::all - all command
76              
77             =head1 DESCRIPTION
78              
79             L is the command to execute "giblog build", "giblog save", "giblog publish", and "giblog deploy" at once.
80              
81             =head1 USAGE
82              
83             giblog all -m COMMIT_COMMENT REMOTE_REPOSITORY BRANCH
84             giblog all -m COMMIT_COMMENT --no-build REMOTE_REPOSITORY BRANCH
85             giblog all -m COMMIT_COMMENT --no-save REMOTE_REPOSITORY BRANCH
86             giblog all -m COMMIT_COMMENT --no-publish REMOTE_REPOSITORY BRANCH
87             giblog all -m COMMIT_COMMENT --no-deploy REMOTE_REPOSITORY BRANCH
88            
89             =head1 METHODS
90              
91             L inherits all methods from L and
92             implements the following new ones.
93              
94             =head2 run
95              
96             $command->run('-m', $message, $remote_repository, $branch);
97             $command->run('-m', $message, '--no-build', $remote_repository, $branch);
98             $command->run('-m', $message, '--no-save', $remote_repository, $branch);
99             $command->run('-m', $message, '--no-publish', $remote_repository, $branch);
100             $command->run('-m', $message, '--no-deploy', $remote_repository, $branch);
101              
102             all command executes the following git commands(giblog build, giblog save, giblog publish).
103              
104             This is the same as the following command. In this example, the commit message is "Hello". the repository name is "origin". the branch name is "main".
105              
106             giblog build
107             giblog save -m "Hello" origin main
108             giblog publish origin main
109              
110             If C<--no-build> option is specified, "giblog build" is not executed.
111              
112             If C<--no-save> option is specified, "giblog save" is not executed.
113              
114             If C<--no-publish> option is specified, "giblog publish" is not executed.
115              
116             If C<--no-deploy> option is specified, "giblog deploy" is not executed.