use File::Temp qw/tempfile/;
use File::Spec qw//;
use Email::LocalDelivery;
+use constant CRON_RAND_DELAY => 60; # adjust as necessary
Getopt::Long::Configure("require_order", "pass_through");
our %opts;
GetOptions(
"sync" => {
doc => "sync target(s) for existing LISTNAME",
arg => "[LISTNAME] [TARGET]",
+ opt => { "cron" => \$opts{cron} }
},
"cat" => {
doc => "show a message by Message-ID",
no strict 'refs';
*{"cmd_$cmd"};
} or die "BUG: $cmd not implemented\n";
+if (my $opt = $cmd{$cmd}->{opt}) {
+ GetOptions(%$opt) or usage(1);
+}
$cmd_sub->(@ARGV);
exit 0;
sub usage {
my ($cmd, $exit) = @_;
my $fd = $exit ? \*STDERR : \*STDOUT;
- print $fd "Usage: ssoma <command> [options] [arguments]\n";
+ print $fd "Usage: ssoma [opts] <command> [command-opts] [args]\n";
print $fd "Available commands:\n" unless $cmd;
# prints out arguments as they should be passed:
my $x = s#[:=]s$## ? '<arg>' :
(s#[:=]i$## ? '<num>' : '');
- print $fd ' ' x 21, join(', ', map { length $_ > 1 ?
+ print $fd ' ' x 14, join(', ', map { length $_ > 1 ?
"--$_" : "-$_" }
split /\|/, $_)," $x\n";
}
sub cmd_sync {
my ($listname, @targets) = @_;
+ if ($opts{cron}) {
+ sleep(rand(CRON_RAND_DELAY));
+ }
if (defined $listname) {
check_listname($listname);
do_sync("$ENV{SSOMA_HOME}/$listname.git", \@targets);