sub getpass {
ReadMode( "noecho");
print "Password: ";
- chomp (my $pwd = <>);
+ chomp (my $pwd = <STDIN>);
ReadMode ("original");
return $pwd;
}
my $default = shift;
print $prompt . ($default ? "[$default]: " : "");
- chomp (my $data = <>);
+ chomp (my $data = <STDIN>);
+
if (!$data) {
$data = $default;
}
+
return $data;
}
my ($hash) = split(" ", $hashtxt);
GetOptions(
+ 'bug=s' => \$opts{bug},
+ 'attach' => \$opts{attach},
+ 'comment=s' => \$opts{comment},
'project=s' => \$opts{project},
'summary=s' => \$opts{summary},
'desc=s' => \$opts{desc},
}
if (!$opts{user}) {
- $opts{user} = getfield("User: ");
+ $opts{user} = getfield("User: ");
}
if (!$opts{pass} && !$opts{debug}) {
- $opts{pass} = getpass();
- print "\n";
+ $opts{pass} = getpass();
+ print "\n";
}
my $jira;
$issue = $jira->GET("/issue/FS-7985") or die "login incorrect:";
}
+if ($opts{bug}) {
+ if ($opts{comment}) {
+
+ if ($opts{comment} eq "edit") {
+ $opts{comment} = get_text();
+ }
+
+ my $input = {
+ update => {
+ comment =>
+ [{
+ add => {
+ body => $opts{comment}
+ }
+ }
+ ]
+ }
+ };
+
+ $jira->PUT("/issue/" . $opts{bug}, undef, $input);
+ print "Comment Posted.\n";
+ }
+
+ if ($opts{attach}) {
+ $jira->attach_files($opts{bug}, @ARGV);
+ printf "%d file%s attached.\n", scalar @ARGV, scalar @ARGV == 1 ? "" : "s";
+ }
+
+ exit;
+}
+
+
#print $issue->{key};
#exit;
} else {
$issue = $jira->POST('/issue', undef, $input) or die "Issue was not created:";
print "Issue Posted: " . $issue->{key};
+
+ if ($opts{attach}) {
+ $jira->attach_files($issue->{key}, @ARGV);
+ printf "%d file%s attached.\n", scalar @ARGV, scalar @ARGV == 1 ? "" : "s";
+ }
}