Alt-CPAN-Uploader-tinyua

 view release on metacpan or  search on metacpan

bin/cpan-upload  view on Meta::CPAN

use Getopt::Long::Descriptive 0.084;

=head1 USAGE

  usage: cpan-upload [options] file-to-upload-1 [ file-to-upload-2 ... ]
    -v --verbose       enable verbose logging
    -h --help          display this help message
    --dry-run          do not actually upload anything

    -u --user          your PAUSE username
    -p --password      the password to your PAUSE account
    -d --directory     a dir in your CPAN space in which to put the file
    --http-proxy       URL of the http proxy to use in uploading

=head1 CONFIGURATION

If you have a C<.pause> file in your home directory, it will be checked for a
username and password.  It should look like this:

  user EXAMPLE
  password your-secret-password

You can GnuPG-encrypt this file if you wish:

    # Follow the prompts, setting your key as the "recipient"
    # Use ^D once you've finished typing out your authentication information
    gpg -ea > $HOME/.pause
    # OR, encrypt a file you already created:
    gpg -ea $HOME/.pause && mv $HOME/.pause{.asc,}

=head1 SEE ALSO

bin/cpan-upload  view on Meta::CPAN


# Process arguments
my ($opt, $usage) = describe_options(
  "usage: %c [options] file-to-upload",

  [ "verbose|v" => "enable verbose logging" ],
  [ "help|h"    => "display this help message" ],
  [ "dry-run"   => "do not actually upload anything" ],
  [],
  [ "user|u=s"      => "your PAUSE username" ],
  [ "password|p=s"  => "the password to your PAUSE account" ],
  [ "directory|d=s" => "a dir in your CPAN space in which to put the files" ],
  [ "http-proxy=s"  => "URL of the http proxy to use in uploading" ],
  [ "config|c=s"    => "config file to use; defaults to ~/.pause" ],
);

if ($opt->help) {
  print $usage->text;
  exit;
}

my $from_file = CPAN::Uploader->read_config_file($opt->config);

die "Please provide at least one file name.\n" . $usage unless @ARGV;

$arg{user} = $opt->_specified('user') ? $opt->user : $from_file->{user};

die "Please provide a value for --user\n" unless defined $arg{user};

$arg{user} = uc $arg{user};

$arg{password} = $opt->password if $opt->_specified('password');

if (
  ! $arg{password}
  and defined $from_file->{user}
  and ($arg{user} eq uc $from_file->{user})
) {
  $arg{password} = $from_file->{password};
}

$arg{debug}  = 1 if $opt->verbose;
$arg{subdir} = $opt->directory if defined $opt->directory;

$arg{ $_ } = $opt->$_ for grep { defined $opt->$_ } qw(dry_run http_proxy);

if (! $arg{password}) {
  require Term::ReadKey;
  local $| = 1;
  print "PAUSE Password: ";
  Term::ReadKey::ReadMode('noecho');
  chop($arg{password} = <STDIN>);
  Term::ReadKey::ReadMode('restore');
  print "\n";
}

foreach my $file (@ARGV) {
  CPAN::Uploader->upload_file(
    $file,
    \%arg,
  );
}

lib/CPAN/Uploader.pm  view on Meta::CPAN


=method upload_file

  CPAN::Uploader->upload_file($file, \%arg);

  $uploader->upload_file($file);

Valid arguments are:

  user       - (required) your CPAN / PAUSE id
  password   - (required) your CPAN / PAUSE password
  subdir     - the directory (under your home directory) to upload to
  http_proxy - uri of the http proxy to use
  upload_uri - uri of the upload handler; usually the default (PAUSE) is right
  debug      - if set to true, spew lots more debugging output

This method attempts to actually upload the named file to the CPAN.  It will
raise an exception on error.

=cut

lib/CPAN/Uploader.pm  view on Meta::CPAN

  my $file = shift;

  $self->log("registering upload with " . $self->target . " web server");

  my $agent = HTTP::Tiny::UA->new(
    agent => $self->_ua_string,
    ($self->{http_proxy} ? (http_proxy => $self->{http_proxy}) : ()),
  );

  my $uri = URI->new($self->{upload_uri} || $UPLOAD_URI);
  $uri->userinfo(join ':', $self->{user}, $self->{password});

  # Make the request to the PAUSE web server
  $self->log("POSTing upload for $file to $uri");
  my $response = $agent->post_multipart($uri, {
    HIDDENNAME                        => $self->{user},
    CAN_MULTIPART                     => 1,
    pause99_add_uri_upload            => File::Basename::basename($file),
    SUBMIT_pause99_add_uri_httpupload => " Upload this file from my disk ",
    pause99_add_uri_uri               => "",
    pause99_add_uri_httpupload        => {

lib/CPAN/Uploader.pm  view on Meta::CPAN

This method returns a new uploader.  You probably don't need to worry about
this method.

Valid arguments are the same as those to C<upload_file>.

=cut

sub new {
  my ($class, $arg) = @_;

  $arg->{$_} or Carp::croak("missing $_ argument") for qw(user password);
  bless $arg => $class;
}

=method read_config_file

  my $config = CPAN::Uploader->read_config_file( $filename );

This reads the config file and returns a hashref of its contents that can be
used as configuration for CPAN::Uploader.



( run in 0.654 second using v1.01-cache-2.11-cpan-49f99fa48dc )