#!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} = ; } 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;