package make::console;
BEGIN {
- require 5.8.0;
+ require 5.10.0;
}
+use feature ':5.10';
use strict;
use warnings FATAL => qw(all);
sub print_format($;$) {
my $message = shift;
- my $stream = shift || *STDOUT;
+ my $stream = shift // *STDOUT;
while ($message =~ /(<\|(\S+)\s(.+?)\|>)/) {
my $formatted = __console_format $2, $3;
$message =~ s/\Q$1\E/$formatted/;
$answer = rel2abs(prompt_string($interactive, $question, $default));
$create = prompt_bool($interactive && !-d $answer, "$answer does not exist. Create it?", 'y');
if ($create && $create_now) {
- my $mkpath = eval {
- mkpath($answer, 0, 0750);
- return 1;
- };
- unless (defined $mkpath) {
- print_warning "unable to create $answer!\n";
+ unless (create_directory $answer, 0750) {
+ print_warning "unable to create $answer: $!\n";
$create = 0;
}
}
print_format "$question\n";
print_format "[<|GREEN $default|>] => ";
chomp(my $answer = <STDIN>);
- print "\n";
+ say '';
return $answer ? $answer : $default;
}