chiark / gitweb /
wip tb-list
[topbloke.git] / tb-list.pl
diff --git a/tb-list.pl b/tb-list.pl
new file mode 100755 (executable)
index 0000000..6be99af
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+# usage: tb-list [<patch-spec>]
+#  lists all patches matching <patch-spec> and other criteria
+
+use warnings;
+use strict;
+
+use Getopt::Long;
+use Topbloke;
+
+Getopt::Long::Configure(qw(bundling));
+
+our $deleted=0;
+our $deleted_only=0;
+our $current=0;
+our $related=0;
+our $leaves=0;
+our $sort='';
+
+GetOptions("d|deleted!" => \$deleted,         # including deleted patches
+          "deleted-only!" => \$deleted_only, # only deleted patches
+          "r|related=s" => \$related,       # only patches related to this one
+          "l|last|leaf|leaves" => \$leaves, # only leaf patches
+          "sort=s" => \$sort,
+    ) or die "bad options\n";
+
+our $spec;
+
+if (@ARGV==1) {
+    $spec = parse_patch_spec($ARGV[0]);
+} elsif (!@ARGV) {
+} else {
+    die "too many arguments\n";
+}
+
+our @sort = grep { /./ } split m/,/, $sort;
+push @sort, $spec ? 'created' : 'topo';
+foreach $sort (@sort) {
+    die "bad sort $sort\n" unless grep { $_ eq $sort } 
+        qw(fullname created nick topo);
+}
+
+use Data::Dumper;
+
+foreach_patch($spec, $deleted || $deleted_only, [], sub {
+    print Dumper(\@_);
+             });