diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-05-25 09:46:22 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-05-25 09:46:22 +0300 |
commit | b8ea8b4038eab296f9aa64aa5b60922f9cf63c1a (patch) | |
tree | 4f55d49ec4eedce7d2b3614b21e1613a60c9ac24 /lib/App | |
parent | a5e383a975b4ab3ca9012521953eb3c64277072a (diff) | |
download | glacier-b8ea8b4038eab296f9aa64aa5b60922f9cf63c1a.tar.gz glacier-b8ea8b4038eab296f9aa64aa5b60922f9cf63c1a.tar.bz2 |
Change put arguments
By default, the command expects one or more names of the local files
and uploads them under their base names. The -r (--rename) option
changes this behavior. With this option, exactly three arguments are
expected: the vault name, the name of the local file, and the name for
that file in the vault directory.
* lib/App/Glacier/Command/Put.pm: Remove the -m (--multiple)
option. Replace it with the -r (--rename) option of the opposite
meaning. Accept one or more files to upload by default.
Diffstat (limited to 'lib/App')
-rw-r--r-- | lib/App/Glacier/Command/Put.pm | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/lib/App/Glacier/Command/Put.pm b/lib/App/Glacier/Command/Put.pm index 954488c..11070bb 100644 --- a/lib/App/Glacier/Command/Put.pm +++ b/lib/App/Glacier/Command/Put.pm @@ -19,19 +19,27 @@ glacier put - upload file to a vault =head1 SYNOPSIS B<glacier put> -[B<-mq>] +[B<-q>] [B<-j> I<NJOBS>] [B<--jobs=>I<NJOBS>] -[B<--multiple>] [B<--quiet>] I<VAULT> -I<FILE> -[I<REMOTENAME>] +I<FILE> [I<FILE>...] + +B<glacier put> +B<-r> | B<--rename>] +[B<-q>] +[B<-j> I<NJOBS>] +[B<--jobs=>I<NJOBS>] +[B<--quiet>] +I<VAULT> +I<FILE> I<REMOTENAME> + =head1 DESCRIPTION -Uploads I<FILE> to I<VAULT>. If I<REMOTENAME> is given, it supplies the new -name for the file. +Uploads I<FILE>s to I<VAULT>. With B<--rename> option, uploads single +I<FILE> and assings I<REMOTENAME> to the copy in the vault. =head1 OPTION @@ -48,11 +56,12 @@ The default is configured by the B<transfer.upload.jobs> configuration statement. If absent, the B<transfer.jobs> statement is used. The default value is 16. -=item B<-m>, B<--multiple> +=item B<-r>, B<--rename> + +Uploads single file with a different remote name. Exactly three arguments are +expected: the name of the vault, the name of the local file to upload and the +name to assign to the remote copy. -Upload multiple files. All command line arguments after I<VAULT> are treated -as the names of local files to upload. - =back =head1 SEE ALSO @@ -65,13 +74,18 @@ sub getopt { my ($self, %opts) = @_; return $self->SUPER::getopt('jobs|j=i' => \$self->{_options}{jobs}, 'quiet|q' => \$self->{_options}{quiet}, - 'multiple|m' => \$self->{_options}{multiple}, + 'rename|r' => \$self->{_options}{rename}, %opts); } sub run { my $self = shift; - if ($self->{_options}{multiple}) { + if ($self->{_options}{rename}) { + $self->abend(EX_USAGE, "exactly three arguments expected") + unless @_ == 3; + my ($vaultname, $localname, $remotename) = @_; + $self->_upload($vaultname, $localname, $remotename); + } else { $self->abend(EX_USAGE, "too few arguments") if @_ < 2; my $vaultname = shift; my @failed_uploads; @@ -91,16 +105,11 @@ sub run { if (@failed_uploads == @_) { exit(EX_FAILURE); } else { - $self->error("following files failed to upload: " + $self->error("the following files failed to upload: " . join(', ', @failed_uploads)); exit(EX_UNAVAILABLE); } } - } else { - $self->abend(EX_USAGE, "two or three arguments expected") - unless @_ == 2 || @_ == 3; - my ($vaultname, $localname, $remotename) = @_; - $self->_upload($vaultname, $localname, $remotename); } } @@ -114,7 +123,6 @@ sub abend { } } - sub _upload { my ($self, $vaultname, $localname, $remotename) = @_; |