]> git.donarmstrong.com Git - debhelper.git/commitdiff
dh: Add --list option to list available addons.
authorColin Watson <cjwatson@debian.org>
Thu, 13 Aug 2009 08:03:34 +0000 (09:03 +0100)
committerJoey Hess <joey@gnu.kitenet.net>
Sun, 16 Aug 2009 16:36:32 +0000 (12:36 -0400)
debian/changelog
dh

index cf1bcd3a11e017e916a8783154787f2230927e1a..7df41d4d0e02980e21dd63bd9cb29bd9d03aa81d 100644 (file)
@@ -1,3 +1,9 @@
+debhelper (7.3.14) UNRELEASED; urgency=low
+
+  * dh: Add --list option to list available addons.
+
+ -- Colin Watson <cjwatson@debian.org>  Thu, 13 Aug 2009 09:00:24 +0100
+
 debhelper (7.3.13) unstable; urgency=low
 
   [ Bernd Zeimetz ]
diff --git a/dh b/dh
index 2a6c0a31cf1fa6f87969dbc8e2a35900b7428356..2e7385f4ec7f286bd197c53bc388087a899fc5dd 100755 (executable)
--- a/dh
+++ b/dh
@@ -8,10 +8,11 @@ dh - debhelper command sequencer
 
 use strict;
 use Debian::Debhelper::Dh_Lib;
+use File::Spec;
 
 =head1 SYNOPSIS
 
-B<dh> sequence [B<--with> I<addon>[,I<addon>,...]] [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining>] [S<I<debhelper options>>]
+B<dh> sequence [B<--with> I<addon>[,I<addon>,...]] [B<--list>] [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining>] [S<I<debhelper options>>]
 
 =head1 DESCRIPTION
 
@@ -58,6 +59,10 @@ the sequence addon interface.
 
 The inverse of --with, disables using the given addon.
 
+=item B<--list>, B<-l>
+
+List all available addons.
+
 =item B<--until> I<cmd>
 
 Run commands in the sequence until and including I<cmd>, then stop.
@@ -216,6 +221,8 @@ init(options => {
                my ($option,$value)=@_;
                @{$dh{WITH}} = grep { $_ ne $value } @{$dh{WITH}};
        },
+       "l" => \$dh{LIST},
+       "list" => \$dh{LIST},
 });
 inhibit_log();
 
@@ -327,6 +334,29 @@ sub add_command {
        my $sequence=shift;
        unshift @{$sequences{$sequence}}, $command;
 }
+
+if ($dh{LIST}) {
+       my %addons;
+
+       for my $inc (@INC) {
+               my $path = File::Spec->catdir($inc, "Debian/Debhelper/Sequence");
+               if (-d $path) {
+                       for my $module_path (glob "$path/*.pm") {
+                               my $name = basename($module_path);
+                               $name =~ s/\.pm$//;
+                               $name =~ s/_/-/g;
+                               $addons{$name} = 1;
+                       }
+               }
+       }
+
+       for my $name (sort keys %addons) {
+               print "$name\n";
+       }
+
+       exit 0;
+}
+
 foreach my $addon (@{$dh{WITH}}) {
        my $mod="Debian::Debhelper::Sequence::$addon";
        $mod=~s/-/_/g;