diff --git a/ChangeLog b/ChangeLog index c8db122..8018b24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ yapfaq 1.1.0 (unreleased) * Disabled projects must be posted, if forced. * Warn of unencoded 8bit characters in header or body if -d is set. * Update POD. + * Add an option for a common headers file for all projects. yapfaq 1.0.1 (2025-01-24) * Add %t placeholder for Message-ID (feature parity with 0.9). diff --git a/bin/yapfaq.pl b/bin/yapfaq.pl index 3c018d1..210015b 100755 --- a/bin/yapfaq.pl +++ b/bin/yapfaq.pl @@ -45,6 +45,8 @@ $Config{'nntp-pass'} = ''; # password for AUTHINFO $Config{'force-auth'} = 0; # set to 1 to force authentication $Config{'starttls'} = 0; # set to 1 to use STARTTLS if possible +$Config{'xtraheaders'} = ''; # path to file with extra headers + $Config{'verbose'} = 0; # set to 1 to get status messages $Config{'debug'} = 0; # set to 1 to get some debug output, # set to 2 for NNTP debug output @@ -100,6 +102,7 @@ GetOptions ('p|project=s' => \$OptProject, 'nntp-pass=s' => \$Config{'nntp-pass'}, 'starttls!' => \$Config{'starttls'}, 'force-auth!' => \$Config{'force-auth'}, + 'xtraheaders=s' => \$Config{'xtraheaders'}, 'v|verbose!' => \$Config{'verbose'}, 'd|debug!' => \$Config{'debug'}, 'c|config' => \&ShowConf, @@ -377,6 +380,11 @@ sub BuildPosting { warn "W: '$BodyFile' not found.\n"; return ''; } + my $XtraHeaderFile = $Config{'xtraheaders'} if $Config{'xtraheaders'}; + if ($Config{'xtraheaders'} && not -r $XtraHeaderFile) { + warn "W: '$XtraHeaderFile' not found.\n"; + return ''; + } # today (TD) my $TD = DateTime->now->set_time_zone('local'); @@ -404,6 +412,10 @@ sub BuildPosting { print "- Reading headers ($Project.hdr) and body ($Project.txt).\n" if $Config{'debug'}; my @Headers = path($HeaderFile)->lines; my @Body = path($BodyFile)->lines; + if ($Config{'xtraheaders'}) { + print "- Reading extra headers ($XtraHeaderFile).\n" if $Config{'debug'}; + push @Headers, path($XtraHeaderFile)->lines ; + } my %Header = &ParseHeaders(@Headers); # check for mandatory headers @@ -748,6 +760,14 @@ Use a TLS encrypted connection (via STARTTLS) if available. You can override this option on the command line by using B<--starttls> or B<--nostarttls> accordingly. +=item B = I + +Path to a file with common headers for all project files. Those +headers will be appended to each project. + +You can override this option on the command line by using +B<--xtraheaders> = I. + =back =head2 Project files