introduce rrr-init; this adds a new dependency File::File::Rule; remove the mention...
[rersyncrecent.git] / bin / rrr-init
bloba161c2ca9533ecd9932102adae7b2f2dbd8ed2ac
1 #!/usr/bin/perl -- -*- mode: cperl -*-
3 =head1 NAME
5 rrr-init - set up RECENT files for a directory tree
7 =head1 SYNOPSIS
9 rrr-init [options] directory
11 =head1 OPTIONS
13 =over 8
15 =cut
17 my @opt = <<'=back' =~ /B<--(\S+)>/g;
19 =item B<--aggregator=s>
21 Comma separated list of aggregator specifications, e.g.
23 --aggregator=1h,6h,1d,1W,1M,1Q,1Y,Z
25 Defaults to C<1h,1d,1M,1Y,Z>
27 =item B<--help|h>
29 Prints a brief message and exists.
31 =item B<--verbose|v+>
33 More feedback.
35 =back
37 =head1 DESCRIPTION
39 Walk through a tree and fill all files into initial recentfiles.
41 =cut
44 use strict;
45 use warnings;
47 use File::Find::Rule;
48 use lib "/home/k/sources/rersyncrecent/lib";
49 use File::Rsync::Mirror::Recent;
50 use File::Rsync::Mirror::Recentfile;
51 use File::Spec;
52 use Getopt::Long;
53 use Pod::Usage qw(pod2usage);
54 use Time::HiRes qw(time);
56 our %Opt;
57 GetOptions(\%Opt,
58 @opt,
59 ) or pod2usage(1);
61 if ($Opt{help}) {
62 pod2usage(0);
65 if (@ARGV != 1) {
66 pod2usage(1);
69 my($rootdir) = @ARGV;
70 my $aggregator_string = $Opt{aggregator} || "1h,1d,1M,1Y,Z";
71 my @aggregator = split /\s*,\s*/, $aggregator_string;
72 my $localroot = File::Spec->rel2abs($rootdir);
73 my $rf = File::Rsync::Mirror::Recentfile->new
75 aggregator => \@aggregator,
76 interval => $aggregator[0],
77 localroot => $localroot,
78 verbose => $Opt{verbose},
81 foreach my $file ( map {$_->[1]} sort {$a->[0] <=> $b->[0]} map {[-M $_, $_]} File::Find::Rule->new->file->in($rootdir) ) {
82 $rf->update(File::Spec->rel2abs($file),"new");
85 __END__
88 # Local Variables:
89 # mode: cperl
90 # coding: utf-8
91 # cperl-indent-level: 4
92 # End: