App-CPAN-Mini-Visit

 view release on metacpan or  search on metacpan

lib/App/CPAN/Mini/Visit.pm  view on Meta::CPAN

    return 1;
}

sub _exit_bad_minicpan {
    my ($dir) = @_;
    die "requires directory argument" unless defined $dir;
    print STDERR << "END_BAD_MINICPAN";
Directory '$dir' does not appear to be a CPAN repository.

END_BAD_MINICPAN
    return 1;
}

sub _exit_usage {
    my $exe = basename($0);
    print STDERR << "END_USAGE";
Usage:
  $exe [OPTIONS] [PROGRAM]

  $exe [OPTIONS] -- [PROGRAM] [ARGS]

Options:

 --append|-a        --append=dist -> append distname after ARGS
                    --append=path -> append tarball path after ARGS

 -e|-E              run next argument via 'perl -E'
 
 --help|-h          this usage info 

 --minicpan|-m      directory of a minicpan (defaults to local minicpan 
                    from CPAN::Mini config file)

 --output|-o        file to save output instead of sending to terminal

 --quiet|-q         silence warnings and suppress STDERR from tar

 --version|-V       $exe program version

 --                 indicates the end of options for $exe


END_USAGE
    return 1;
}

sub _exit_version {
    print STDERR basename($0) . ": $VERSION\n";
    return 1;
}

sub _visit {
    my ( $archive, @cmd_line ) = @_;

    my $tempd = tempd;

    my $ae = Archive::Extract->new( archive => $archive );

    my $olderr;

    # stderr > /dev/null if quiet
    if ( !$Archive::Extract::WARN ) {
        open $olderr, ">&STDERR";
        open STDERR, ">", File::Spec->devnull;
    }

    my $extract_ok = $ae->extract;

    # restore stderr if quiet
    if ( !$Archive::Extract::WARN ) {
        open STDERR, ">&", $olderr;
        close $olderr;
    }

    if ( !$extract_ok ) {
        warn "Couldn't extract '$archive'\n" if $Archive::Extract::WARN;
        return;
    }

    # most distributions unpack a single directory that we must enter
    # but some behave poorly and unpack to the current directory
    my @children = dir()->children;
    if ( @children == 1 && -d $children[0] ) {
        chdir $children[0];
    }

    # execute command
    my $rc = system(@cmd_line);
    if ( $rc == -1 ) {
        warn "Error running '@cmd_line': $!\n";
    }

    return;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::CPAN::Mini::Visit - explore each distribution in a minicpan repository

=head1 VERSION

version 0.008

=head1 SYNOPSIS

    #!/usr/bin/perl
    use App::CPAN::Mini::Visit;
    exit App::CPAN::Mini::Visit->run;

=head1 DESCRIPTION

This module contains the guts of the L<visitcpan> program.  See documentation of
that program for details on features and command line options.

=head1 USAGE

=head2 C<run>

    exit App::CPAN::Mini::Visit->run();

Executes the program, processing command line arguments and traversing



( run in 2.302 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )