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

added command to download attachments

parent be425440
No related branches found
No related tags found
No related merge requests found
......@@ -56,8 +56,12 @@ EOPOD
=head2 Overview
help [topic] (this overview)
list
show ticket
list ... list tickets in current project
show ticket ... show ticket with this number
att ticket nr ... download attachment nr <nr> from ticket <ticket>
instances ... list all instances
projects ... list all projects
=cut
EOPOD
......@@ -375,6 +379,17 @@ sub interpret
$self->{ticket_number}= $ticket_number;
}
}
elsif ($op_mode eq 'att')
{
my $rm= $mRM->attach();
push (@$pars, $self->{ticket_number}) if (!@$pars && exists ($self->{ticket_number}));
my $att_nr= $pars->[1];
foreach my $ticket_number (@$pars)
{
Redmine::CLI::download_attachment ($rm, $ticket_number, $att_nr);
$self->{ticket_number}= $ticket_number;
}
}
elsif ($op_mode eq 'browse' || $op_mode eq 'display')
{
my $rm_cfg= $self->{_rm_cfg};
......@@ -726,6 +741,29 @@ sub show_issue
$issue;
}
sub download_attachment
{
my $rm= shift;
my $ticket_number= shift;
my $number= shift || 0;
my $ua= $rm->{ua};
return undef unless (defined ($ua));
my $issue= $rm->issue( $ticket_number, { include => 'attachments' } );
my $attachments= $issue->{issue}->{attachments};
# print "attachments: ", Dumper ($attachments);
return undef unless (defined ($attachments));
my $attachment= $attachments->[$number];
return undef unless (defined ($attachment));
print "attachment: ", Dumper ($attachment);
$ua->get($attachment->{content_url}, ':content_file' => $attachment->{filename});
$attachment;
}
sub usage
{
my $pod= new Pod::Simple::Text();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment