Bug 33285: Allow specifying the delimeter for runreport.pl

To test:
1 - Write a report in koha
2 - perl misc/cronjobs/runreport.pl --format csv 1 (or correct report number)
3 - Note you get commas
4 - Apply patch
5 - Repeat #2 - no change
6 - perl misc/cronjobs/runreport.pl --format csv --separator "|" 1
7 - Now it is pipe delimited
8 - perl misc/cronjobs/runreport.pl --format tsv --separator "|" 1
9 - Error is reported, you cannot set separator unless csv
10 - Try other separators

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-03-20 20:08:56 +00:00 committed by Tomas Cohen Arazi
parent 92e3793eb8
commit bad0d52245
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -183,6 +183,7 @@ my $separator = ',';
my $quote = '"';
my $store_results = 0;
my $csv_header = 0;
my $csv_separator = "";
my $username = undef;
my $password = undef;
@ -195,6 +196,7 @@ GetOptions(
'man' => \$man,
'verbose' => \$verbose,
'format=s' => \$format,
'separator=s' => \$csv_separator,
'to=s' => \$to,
'from=s' => \$from,
'subject=s' => \$subject,
@ -219,6 +221,14 @@ unless ($format) {
$format = 'text';
}
if( $csv_separator ){
if( $format eq 'csv' ) {
$separator = "$csv_separator";
} else {
print STDERR "Cannot specify separator if not using CSV format\n";
}
}
if ($format eq 'tsv' || $format eq 'text') {
$format = 'csv';
$separator = "\t";