Skip to content

Instantly share code, notes, and snippets.

@mattn
Forked from mattn/release.pl
Created January 5, 2009 08:33
Show Gist options
  • Save mattn/43327 to your computer and use it in GitHub Desktop.
Save mattn/43327 to your computer and use it in GitHub Desktop.
#!perl
use strict;
use warnings;
use Config::Pit;
use Getopt::Long;
use WWW::Mechanize;
use Perl6::Say;
my $conf = pit_get("vim.com", require => {
"username" => "your username on vim.org", # NOTE: do not edit this line
"password" => "your password on vim.org", # NOTE: do not edit this line
});
my %args = ( id => '', sv => '', vv => '7.0', msg => '' );
die "invalid args"
unless GetOptions(\%args, 'id=i', 'sv=s', 'vv=f', 'msg=s');
unless ($args{msg}) {
print "message: ";
$args{msg} = <STDIN>;
}
my $file = shift;
die "script version not specified" unless $args{id};
die "message not specified" unless $args{msg};
die "file not specified" unless $file;
my $mech = WWW::Mechanize->new;
$mech->get('http://www.vim.org/login.php');
$mech->submit_form(
form_name => 'login',
fields => {
userName => $conf->{username},
password => $conf->{password},
},
);
$mech->get("http://www.vim.org/scripts/add_script_version.php?script_id=$args{id}");
$mech->form_name('script');
$mech->field(script_file => $file);
$mech->select('vim_version', $args{vv});
$mech->field(script_version => $args{sv});
$mech->field(version_comment => $args{msg});
my $res = $mech->click('add_script');
say $res->is_success ? "uploaded" : $res->status_line;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment