'r' => \$rebuild_dot_folders,
) or pod2usage();
$help and pod2usage(-exitstatus=>0, -verbose=>1);
-@ARGV == 0 or pod2usage();
+@ARGV <= 1 or pod2usage();
}
our $run = !$norun;
$rebuild_dot_folders and exit(create_dot_folders);
- chdir("$MAILDIR/new") or die("chdir($MAILDIR/new): $!");
+ my @files;
+ # XXX some options:
+ # a. take message numbers on stdin
+ # b. take full paths to messages on stdin
+ # c. take standard [msgs] list on command-line
+ # d. assume inc has just finished so cur points to start of new mail and
+ # just do cur-last
+ # Hacked up b. here, but I'm not happy with it. I'm renaming files that
+ # stay in inbox for no reason, and leaving gaping holes. Any of the above
+ # approaches has those problems, and the solution is always the same:
+ # # Keep track of the message numbers we've renamed out of inbox
+ # my @filtered;
+ # for (@msgs) {
+ # if (!my $new = filter($_)) {
+ # # If @filtered is empty, this message already has the right number.
+ # $new = shift(@filtered) || next;
+ # }
+ # push(@filtered, $_);
+ # rename($_, $new);
+ # }
+
+ if (@ARGV > 0) {
+ # XXX if sticking with this approach, reject arg other than '-'
+ chomp(@files = <>);
+ @files > 0 || exit 0;
+ } else {
+ chdir("$MAILDIR/new") or die("chdir($MAILDIR/new): $!");
+ @files = getfiles('.');
+ }
+
my %folders = filter_mail(map { $_->[1] }
sort { $a->[0] <=> $b->[0] }
map {
}
[$st->mtime, $_]
}
- getfiles('.'));
+ @files);
$run and %folders and update_dot_folders(\%folders);