Giblog
view release on metacpan or search on metacpan
lib/Giblog/Command/all.pm view on Meta::CPAN
package Giblog::Command::all;
use base 'Giblog::Command';
use strict;
use warnings;
use Mojolicious;
use Time::Piece 'localtime';
use Getopt::Long 'GetOptions';
use Carp 'confess';
sub run {
my ($self, @argv) = @_;
my $message;
my $has_no_build_option;
my $has_no_save_option;
my $has_no_publish_option;
my $has_no_deploy_option;
{
local @ARGV = @argv;
my $getopt_option_all = Getopt::Long::Configure(qw(default no_auto_abbrev no_ignore_case));
GetOptions(
'm=s' => \$message,
'no-build' => \$has_no_build_option,
'no-save' => \$has_no_save_option,
'no-publish' => \$has_no_publish_option,
'no-deploy' => \$has_no_deploy_option,
);
Getopt::Long::Configure($getopt_option_all);
@argv = @ARGV;
}
my ($remote_rep, $branch) = @argv;
my $api = $self->api;
my $home_dir = $api->rel_file('.');
unless ($has_no_build_option) {
my @giblog_build_command = ('giblog', '-C', $home_dir, 'build');
if (system(@giblog_build_command) == -1) {
confess "Fail giblog all command. Command is @giblog_build_command: $?";
}
}
unless ($has_no_save_option) {
my @giblog_save_command = ('giblog', '-C', $home_dir, 'save', '-m', $message, $remote_rep, $branch);
if(system(@giblog_save_command) == -1) {
confess "Fail giblog all command. Command is @giblog_save_command : $?";
}
}
unless ($has_no_publish_option) {
my @giblog_publish_command = ('giblog', '-C', $home_dir, 'publish', $remote_rep, $branch);
if (system(@giblog_publish_command) == -1) {
confess "Fail giblog all command. Command is @giblog_publish_command : $?";
}
}
unless ($has_no_deploy_option) {
my @giblog_deploy_command = ('giblog', '-C', $home_dir, 'deploy');
if (system(@giblog_deploy_command) == -1) {
confess "Fail giblog all command. Command is @giblog_deploy_command: $?";
}
}
}
1;
=encoding utf8
=head1 NAME
Giblog::Command::all - all command
=head1 DESCRIPTION
L<Giblog::Command::all> is the command to execute "giblog build", "giblog save", "giblog publish", and "giblog deploy" at once.
=head1 USAGE
( run in 0.723 second using v1.01-cache-2.11-cpan-a9496e3eb41 )