diff -r a5d087334439 -r dd11d1262b6c bin/imager.list --- a/bin/imager.list Sat Jul 25 17:16:13 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -#! /usr/bin/perl - -use 5.010; -use strict; -use warnings; -use Pod::Usage; -use Hash::Util qw(lock_keys); -use File::Find; -use Digest::MD5 qw(md5_hex); -use File::Basename; -use autodie qw(:all); -use Imager; - -use Getopt::Long; - -our %o = ( - latest => undef, -); -lock_keys(%o); - -MAIN: { - my $dir; - - Getopt::Long::Configure qw(Bundling); - GetOptions( - "latest" => \$o{latest}, - "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, - "m|man" => sub { - pod2usage( - -verbose => 2, - -exit => 0, - -noperldoc => system( - "perldoc -V 1>/dev/null - 2>&1" - ) - ); - }, - ) - and defined ($dir = shift) - or pod2usage; - - my (%by_day, %by_dev); - find(sub{ - return if not (-f and /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$/); - my ($host, $dev) = dirname($File::Find::name) =~ /^\Q$dir\/idx\E\/(.+?)(\/.*)/; - push @{$by_day{$_}}, "$host\::$dev"; - push @{$by_dev{"$host\::$dev"}}, $_; - }, "$dir/idx"); - - # by dev - my $l = (sort { $b <=> $a } map { length } keys %by_dev)[0]; - foreach (sort keys %by_dev) { - my $prefix = $_; - foreach ((reverse sort @{$by_dev{$_}})) { - printf "%-*s: %s\n", $l => $prefix, $_; - last if $o{latest}; - $prefix = " "; - } - } - -} - -__END__ - -=head1 NAME - - imager.list - list the images created by imager - -=head1 SYNOPSIS - - imager.list [options] {directory} - -=head1 DESCRIPTION - -B lists the index files (images) the imager created. - - -=head1 OPTIONS - -=over - -=item B<--latest> - -List only the latest backups. (default: list all) - -=item B<-h>|B<--help> - -=item B<-m>|B<--man> - -The short and longer help. - -=back - -=cut