chiark / gitweb /
6be99afd41cc10d4a157ca592e8f3a8677be2d7f
[topbloke.git] / tb-list.pl
1 #!/usr/bin/perl
2 # usage: tb-list [<patch-spec>]
3 #  lists all patches matching <patch-spec> and other criteria
4
5 use warnings;
6 use strict;
7
8 use Getopt::Long;
9 use Topbloke;
10
11 Getopt::Long::Configure(qw(bundling));
12
13 our $deleted=0;
14 our $deleted_only=0;
15 our $current=0;
16 our $related=0;
17 our $leaves=0;
18 our $sort='';
19
20 GetOptions("d|deleted!" => \$deleted,         # including deleted patches
21            "deleted-only!" => \$deleted_only, # only deleted patches
22            "r|related=s" => \$related,       # only patches related to this one
23            "l|last|leaf|leaves" => \$leaves, # only leaf patches
24            "sort=s" => \$sort,
25     ) or die "bad options\n";
26
27 our $spec;
28
29 if (@ARGV==1) {
30     $spec = parse_patch_spec($ARGV[0]);
31 } elsif (!@ARGV) {
32 } else {
33     die "too many arguments\n";
34 }
35
36 our @sort = grep { /./ } split m/,/, $sort;
37 push @sort, $spec ? 'created' : 'topo';
38 foreach $sort (@sort) {
39     die "bad sort $sort\n" unless grep { $_ eq $sort } 
40         qw(fullname created nick topo);
41 }
42
43 use Data::Dumper;
44
45 foreach_patch($spec, $deleted || $deleted_only, [], sub {
46     print Dumper(\@_);
47               });