App-JobLog

 view release on metacpan or  search on metacpan

lib/App/JobLog/Command/info.pm  view on Meta::CPAN

package App::JobLog::Command::info;
$App::JobLog::Command::info::VERSION = '1.042';
# ABSTRACT: provides general App::JobLog information

use App::JobLog -command;
use autouse 'File::Temp'          => qw(tempfile);
use autouse 'Pod::Usage'          => qw(pod2usage);
use autouse 'Carp'                => qw(carp);
use autouse 'App::JobLog::Config' => qw(log DIRECTORY);
use Class::Autouse qw(Config File::Spec);

use Modern::Perl;
no if $] >= 5.018, warnings => "experimental::smartmatch";

# using quasi-pod -- == instead of = -- to make this work with Pod::Weaver

sub execute {
    my ( $self, $opt, $args ) = @_;
    $self->simple_command_check($args);
    my ( $fh, $fn ) = tempfile( UNLINK => 1 );
    my ($executable) = reverse File::Spec->splitpath($0);
    my $text;
    my @options = ( -verbose => 2, -exitval => 0, -input => $fn );
    for ( $opt->verbosity ) {
        when ('man') {
            $text =
                $self->_header($executable)
              . $self->_body($executable)
              . $self->_footer($executable);
            my $perldoc =
              File::Spec->catfile( $Config::Config{scriptdir}, 'perldoc' );
            unless ( -e $perldoc ) {
                carp 'Cannot find perldoc. Text will not be paged.';
                push @options, -noperldoc => 1;
            }
        }
        when ('verbose') {
            $text =
                $self->_header($executable)
              . $self->_basic_usage($executable)
              . $self->_footer($executable);
            push @options, -noperldoc => 1;
        }
        default {
            $text =
              $self->_header($executable) . <<END . $self->_footer($executable);

==head1 For More Information

  $executable info --help
END
            push @options, -noperldoc => 1;
        }
    }

    $text = <<END;
$text
==cut
END
    $text =~ s/^==(\w)/=$1/gm;
    print $fh $text;
    $fh->close;
    pod2usage(@options);
}

sub usage_desc { '%c ' . __PACKAGE__->name }

sub abstract { 'describe job log' }

sub full_description {
    <<END
Describes application and provides usage information.

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.717 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )