On Sun, Aug 10, 2008 at 10:23:19PM -0300, Stefano Zacchiroli wrote: > On Sun, Aug 10, 2008 at 07:49:21PM -0400, James Vega wrote: > > I'd throw my vote in for that (and that's what my current version of > > the patch uses). > > Did you forget to attach it?
Attached is just the changes against bts.pl. I've added some documentation (comments welcome) and implemented a suggest adn had for only displaying key/value pairs if there's actually a value to display. The downside I see to using tabs is that the separation between the key/value pairs is rather random. Example output: [EMAIL PROTECTED]:0 % bts status 300000 bug_num 300000 source unknown done NoèlKöthe <[EMAIL PROTECTED]> found_versions 0.51-2 fixed crypt-ssleay/0.51-3 => date 1111072040 fixed_versions crypt-ssleay/0.51-3 found 0.51-2 => msgid <[EMAIL PROTECTED]> id 300000 severity minor location archive log_modified 1111656819 subject libcrypt-ssleay-perl: package description typo(s) and the like originator Florian Zumbiehl <[EMAIL PROTECTED]> pending done archived 1 package libcrypt-ssleay-perl -- James GPG Key: 1024D/61326D40 2003-09-02 James Vega <[EMAIL PROTECTED]>
Index: scripts/bts.pl
===================================================================
--- scripts/bts.pl (revision 1586)
+++ scripts/bts.pl (working copy)
@@ -47,6 +47,8 @@
use Getopt::Long;
use Encode;
+use Scalar::Util qw(looks_like_number);
+
# Funny UTF-8 warning messages from HTML::Parse should be ignorable (#292671)
$SIG{'__WARN__'} = sub { warn $_[0] unless $_[0] =~ /^Parsing of undecoded UTF-8 will give garbage when decoding entities/; };
@@ -949,6 +951,68 @@
print map {qq($_\n)} @{$bugs};
}
+=item status [<bug> | file:<file>] ...
+
+Uses the SOAP interface to output status information for the given bugs
+(or as read from the listed files -- use '-' to indicate STDIN).
+
+Empty status fields are not displayed.
+
+=cut
+
+sub bts_status {
+ my @args = @_;
+
+ my @bugs;
+ for my $bug (@args) {
+ if (looks_like_number($bug)) {
+ push @bugs,$bug;
+ }
+ elsif (m{^file:(.+)}) {
+ my $file = $1;
+ my $fh;
+ if ($file eq '-') {
+ $fh = \*STDIN;
+ }
+ else {
+ $fh = IO::File->new($file,'r') or
+ die "Unable to open $file for reading: $!";
+ }
+ while (<$fh>) {
+ chomp;
+ next if /^\s*\#/;
+ s/\s//g;
+ next unless looks_like_number($_);
+ push @bugs,$_;
+ }
+ }
+ }
+ my $bugs = Devscripts::Debbugs::status(@bugs);
+ my $first = 1;
+ for my $bug (keys %{$bugs}) {
+ print "\n" if not $first;
+ $first = 0;
+ my @keys = grep {$_ ne 'bug_num'}
+ keys %{$bugs->{$bug}};
+ for my $key ('bug_num',@keys) {
+ my $out;
+ if (ref($bugs->{$bug}{$key}) eq 'ARRAY') {
+ $out .= join(',',@{$bugs->{$bug}{$key}});
+ }
+ elsif (ref($bugs->{$bug}{$key}) eq 'HASH') {
+ $out .= join(',',
+ map { $_ .' => '. ($bugs->{$bug}{$key}{$_}||'') }
+ keys %{$bugs->{$bug}{$key}}
+ );
+ }
+ else {
+ $out .= $bugs->{$bug}{$key}||'';
+ }
+ print "$key\t$out\n" if $out;
+ }
+ }
+}
+
=item clone <bug> [new IDs]
The clone control command allows you to duplicate a bug report. It is useful
signature.asc
Description: Digital signature

