From 9c83c0efff9d9800e4f4527c40709e70a8eec18e Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Tue, 20 Jan 2026 08:54:30 +0100 Subject: [PATCH] Add --simulation mode, show next due date. Signed-off-by: Thomas Hochstein --- ChangeLog | 2 ++ bin/yapfaq.pl | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46cc602..daa9831 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ yapfaq 1.0.0 (unreleased) * Complete rewrite. * Add POD. * Fix file handling (UTF8 mode). +* Show next posting date if posting is not due. +* Add --simulation mode. yapfaq 0.10 (unreleased) * Add: Charset definition. diff --git a/bin/yapfaq.pl b/bin/yapfaq.pl index 5c65499..80ce65e 100755 --- a/bin/yapfaq.pl +++ b/bin/yapfaq.pl @@ -88,12 +88,13 @@ $Config{'nntp-server'} = $ENV{'NNTPSERVER'} if ($ENV{'NNTPSERVER'}); $Config{'nntp-port'} = $ENV{'NNTPPORT'} if ($ENV{'NNTPPORT'}); ### read commandline options -my ($OptProject,$OptForce,$OptTest,$OptNewsgroup,$OptOutput); +my ($OptProject,$OptForce,$OptTest,$OptNewsgroup,$OptOutput,$OptSimulation); GetOptions ('p|project=s' => \$OptProject, 'f|force' => \$OptForce, 't|test' => \$OptTest, 'n|newsgroup=s' => \$OptNewsgroup, 'o|output' => \$OptOutput, + 's|simulation' => \$OptSimulation, 'datadir=s' => \$Config{'datadir'}, 'nntp-server=s' => \$Config{'nntp-server'}, 'nntp-port=s' => \$Config{'nntp-port'}, @@ -107,6 +108,12 @@ GetOptions ('p|project=s' => \$OptProject, 'h|help' => \&ShowPOD, 'V|version' => \&ShowVersion) or &ShowUsage; +# -s implies -t and -v +if ($OptSimulation) { + $OptTest = 1; + $Config{'verbose'} = 1; +} + ### create list of @Projects from $Config{'datadir'} unless -p is set my @Projects; if (!$OptProject) { @@ -135,6 +142,7 @@ foreach (@Projects) { # @Posting will be empty ('') if not due my @Posting = &BuildPosting($_); next if !$#Posting; + next if $OptSimulation; # save Message-ID my $LastMID; @@ -505,13 +513,15 @@ sub BuildPosting { # default to 1 month if no (valid) Posting-Frequency is set $PostingFrequency = '1m' if $PostingFrequency !~ /^\d+[dwmy]$/; + my $NextPosted = &AddDuration(&ParseDate($LastPosted),$PostingFrequency) if $LastPosted; # check if posting is due print "- Posting has been forced.\n" if $Config{'debug'} && $OptForce; - if ($OptForce or (!$LastPosted) or ($LastPosted && &AddDuration(&ParseDate($LastPosted),$PostingFrequency) <= DateTime->now)) { + if ($OptForce or (!$LastPosted) or ($LastPosted && $NextPosted <= DateTime->now)) { print "... is due and will be posted.\n" if $Config{'verbose'} or $Config{'debug'}; } else { - print "... is not due.\n" if $Config{'verbose'} or $Config{'debug'}; + printf ("... is not due (next post at %s).\n", $NextPosted->strftime('%Y-%m-%d')) + if $Config{'verbose'} or $Config{'debug'}; return ''; } @@ -578,7 +588,7 @@ yapfaq - Post FAQs to Usenet I<(yet another postfaq)> =head1 SYNOPSIS -B [B<-Vhcfto>] [B<-p> I[B<-n> I] [OPTIONS] +B [B<-cfhotsV>] [B<-p> I[B<-n> I] [OPTIONS] =head1 REQUIREMENTS @@ -840,6 +850,11 @@ projects. Display this man page and exit. +=item B<-s>, B<--simulation> + +Simulation mode. Don't post, just show which projects would be due. +Implies B<--test> and B<--verbose>. + =item B<-t>, B<--test> Test mode. Don't update project status (time and Message-ID of last