Skip to content
Snippets Groups Projects
Commit 9048e220 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

allow selective download of several attachments, attached to one issue

parent 5c98a217
Branches
No related tags found
No related merge requests found
...@@ -281,6 +281,8 @@ sub interpret ...@@ -281,6 +281,8 @@ sub interpret
return undef; return undef;
} }
my @res;
if ($op_mode eq 'help') { usage('help', (@$pars) ? shift (@$pars) : 'overview'); } if ($op_mode eq 'help') { usage('help', (@$pars) ? shift (@$pars) : 'overview'); }
elsif ($op_mode eq 'exit') { return 0; } elsif ($op_mode eq 'exit') { return 0; }
elsif ($op_mode eq 'interact' || $op_mode eq 'i') elsif ($op_mode eq 'interact' || $op_mode eq 'i')
...@@ -338,6 +340,7 @@ sub interpret ...@@ -338,6 +340,7 @@ sub interpret
my $out_tsv= $self->{out_tsv}; my $out_tsv= $self->{out_tsv};
my ($proj_list, $csv)= Redmine::CLI::show_projects ($rm, $out_tsv); my ($proj_list, $csv)= Redmine::CLI::show_projects ($rm, $out_tsv);
$self->{project_list}= $proj_list; $self->{project_list}= $proj_list;
push (@res, $proj_list);
} }
elsif ($op_mode eq 'wiki') elsif ($op_mode eq 'wiki')
{ {
...@@ -375,8 +378,9 @@ sub interpret ...@@ -375,8 +378,9 @@ sub interpret
push (@$pars, $self->{ticket_number}) if (!@$pars && exists ($self->{ticket_number})); push (@$pars, $self->{ticket_number}) if (!@$pars && exists ($self->{ticket_number}));
foreach my $ticket_number (@$pars) foreach my $ticket_number (@$pars)
{ {
Redmine::CLI::show_issue ($rm, $ticket_number); my $issue= Redmine::CLI::show_issue ($rm, $ticket_number);
$self->{ticket_number}= $ticket_number; $self->{ticket_number}= $ticket_number;
push (@res, $issue);
} }
} }
elsif ($op_mode eq 'att') elsif ($op_mode eq 'att')
...@@ -453,7 +457,7 @@ not needed? ...@@ -453,7 +457,7 @@ not needed?
=end comment =end comment
=cut =cut
return 1; return (1, \@res);
} }
sub interact sub interact
...@@ -474,7 +478,7 @@ sub interact ...@@ -474,7 +478,7 @@ sub interact
my ($op, @pars)= split (' ', $l); my ($op, @pars)= split (' ', $l);
print "op=[$op]\n"; print "op=[$op]\n";
my $continue= interpret ($self, $op, \@pars); my ($continue)= interpret ($self, $op, \@pars);
last unless ($continue); last unless ($continue);
} }
} }
...@@ -745,7 +749,7 @@ sub download_attachment ...@@ -745,7 +749,7 @@ sub download_attachment
{ {
my $rm= shift; my $rm= shift;
my $ticket_number= shift; my $ticket_number= shift;
my $number= shift || 0; my $number= shift;
my $ua= $rm->{ua}; my $ua= $rm->{ua};
return undef unless (defined ($ua)); return undef unless (defined ($ua));
...@@ -755,13 +759,25 @@ sub download_attachment ...@@ -755,13 +759,25 @@ sub download_attachment
# print "attachments: ", Dumper ($attachments); # print "attachments: ", Dumper ($attachments);
return undef unless (defined ($attachments)); return undef unless (defined ($attachments));
my $attachment= $attachments->[$number]; my @attachment_numbers;
return undef unless (defined ($attachment)); if (!defined ($number) || $number eq '*') { push (@attachment_numbers, 0 .. $#$attachments); }
print "attachment: ", Dumper ($attachment); elsif ($number =~ /^\d+$/) { @attachment_numbers= $number; }
elsif ($number =~ /^\d[\d,-]*\d$/) { print "number ranges not yet implemented\n"; return undef; }
print __LINE__, " attachment_numbers: ", join(' ', @attachment_numbers), "\n";
$ua->get($attachment->{content_url}, ':content_file' => $attachment->{filename}); my @dl_attachments;
foreach my $num (@attachment_numbers)
{
my $attachment= $attachments->[$num];
next unless (defined ($attachment));
# print __LINE__, " attachment: ", Dumper ($attachment);
print __LINE__, " attachment num=[$num] ", $attachment->{filename}, "\n";
$ua->get($attachment->{content_url}, ':content_file' => $attachment->{filename});
push (@dl_attachments, $attachment);
}
$attachment; return (wantarray) ? @dl_attachments : \@dl_attachments;
} }
sub usage sub usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment