App-JobLog
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/JobLog/Command.pm view on Meta::CPAN
package App::JobLog::Command;
$App::JobLog::Command::VERSION = '1.042';
# ABSTRACT: common functionality of App::JobLog commands
use App::Cmd::Setup -command;
use Modern::Perl;
use App::JobLog::Config qw(columns);
sub opt_spec {
my ( $class, $app ) = @_;
return ( $class->options($app), [ 'help' => "this usage screen" ] );
}
# makes sure everything has some sort of description
sub description {
my ($self) = @_;
# abstract provides default text
my $desc = $self->full_description;
unless ($desc) {
( $desc = $self->abstract ) =~ s/^\s++|\s++$//g;
# ensure initial capitalization
$desc =~ s/^(\p{Ll})/uc $1/e;
# add sentence-terminal punctuation as necessary
$desc =~ s/(\w)$/$1./;
}
# make sure things are wrapped nicely
_wrap( \$desc );
# space between description and options text
$desc .= "\n";
return $desc;
}
# performs text wrapping while preserving the formatting of lines beginning with whitespace
sub _wrap {
my $desc = shift;
require Text::WrapI18N;
$Text::WrapI18N::columns = columns;
my ( $current, @gathered );
for my $line ( $$desc =~ /^(.*?)\s*$/mg ) {
if ( $line =~ /^\S/ ) {
if ($current) {
$current .= " $line";
}
else {
$current = $line;
}
}
else {
push @gathered, Text::WrapI18N::wrap( '', '', $current )
if defined $current;
push @gathered, $line;
$current = undef;
}
}
push @gathered, Text::WrapI18N::wrap( '', '', $current )
if defined $current;
$$desc = join "\n", @gathered;
}
# override to make full description
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.589 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )