From bfa46a1dbcd1dd3ea0d32336243bc344f744aa09 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 10 Apr 2020 11:19:47 +0200 Subject: [PATCH] Bug 24591: Add --help option to misc/devel/get-prepared-letter.pl Also fix code style with perltidy Signed-off-by: Nick Clemens --- misc/devel/get_prepared_letter.pl | 60 ++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/misc/devel/get_prepared_letter.pl b/misc/devel/get_prepared_letter.pl index c6f3101cf9..45f5544d82 100755 --- a/misc/devel/get_prepared_letter.pl +++ b/misc/devel/get_prepared_letter.pl @@ -16,17 +16,71 @@ # You should have received a copy of the GNU General Public License along # with Koha; if not, see . +=head1 NAME + +get-prepared-letter.pl - preview letter content + +=head1 SYNOPSIS + +get-prepared-letter.pl --module MODULE --letter-code CODE [options] + +=head1 OPTIONS + +=over + +=item B<--module MODULE> + +The letter module (acquisition, catalogue, circulation, ...) + +=item B<--letter-code CODE> + +The letter code (DUE, PREDUE, ...) + +=item B<--branchcode BRANCHCODE> + +The letter branchcode + +=item B<--message-transport-type TYPE> + +The message transport type (email, print, ...) + +=item B<--lang LANG> + +The letter language (es-ES, fr-FR, ...) + +=item B<--repeat REPEAT> + +A JSON formatted string that will be used as repeat parameter. See +documentation of GetPreparedLetter for more informations. + +=item B<--tables TABLES> + +A JSON formatted string that will be used as tables parameter. See +documentation of GetPreparedLetter for more informations. + +=item B<--loops LOOPS> + +A JSON formatted string that will be used as loops parameter. See +documentation of GetPreparedLetter for more informations. + +=back + +=cut + use Modern::Perl; use Getopt::Long; use JSON; +use Pod::Usage; use C4::Letters; +my $help; my ( $module, $letter_code, $branchcode, $message_transport_type, $lang, $repeat, $tables, $loops ); GetOptions( + 'help' => \$help, 'module=s' => \$module, 'letter-code=s' => \$letter_code, 'branchcode=s' => \$branchcode, @@ -35,7 +89,11 @@ GetOptions( 'repeat=s' => \$repeat, 'tables=s' => \$tables, 'loops=s' => \$loops, -) or die "Error in command line arguments\n"; +) or pod2usage( -exitval => 2, -verbose => 1 ); + +if ($help) { + pod2usage( -exitval => 0, -verbose => 1 ); +} $repeat = $repeat ? decode_json($repeat) : {}; $tables = $tables ? decode_json($tables) : {}; -- 2.20.1