App-grindperl
view release on metacpan or search on metacpan
lib/App/grindperl.pm view on Meta::CPAN
use v5.10.0;
use strict;
use warnings;
package App::grindperl;
our $VERSION = '0.004';
use autodie;
use Getopt::Lucid ':all';
use Path::Class;
use File::Spec;
use Carp qw/carp croak/;
use File::Copy qw/copy/;
use File::HomeDir 0.98;
use namespace::autoclean;
sub new {
my $class = shift;
my $self = bless {}, $class;
if ( -r $self->config_file ) {
unshift @ARGV, $self->read_config_file;
}
my $opt = Getopt::Lucid->getopt([
Param("jobs|j")->default(9),
Param("testjobs|t")->default(9),
Param("output|o"),
Param("install_root")->default(File::Spec->tmpdir),
Param("prefix"),
Switch("debugging")->default(1),
Switch("threads")->default(1),
Switch("32"),
Switch("porting|p"),
Switch("install"),
Switch("config"),
Switch("cache"),
Switch("man"),
Switch("edit"),
Switch("verbose|v"),
Keypair("additions|A"),
Keypair("define|D"),
List("undefine|U"),
]);
$self->{opt} = $opt;
$self->{is_git} = -d '.git';
return $self;
}
sub opt { return $_[0]->{opt} }
sub is_git { return $_[0]->{is_git} }
sub logfile { return $_[0]->opt->get_output };
sub vlog {
my ($self, @msg) = @_;
return unless $self->opt->get_verbose;
say for map { (my $s = $_) =~ s/\n$//; $s } @msg;
}
sub prefix {
my $self = shift;
my $prefix = $self->opt->get_prefix;
return $prefix if defined $prefix && length $prefix;
my $root = $self->opt->get_install_root;
if ( $self->is_git ) {
my $branch = qx/git symbolic-ref HEAD/;
if ( $? ) {
# HEAD not a symbolic ref?
( run in 0.800 second using v1.01-cache-2.11-cpan-99c4e6809bf )