Skip to content
Snippets Groups Projects
Commit efdf8694 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- fixed output handling if only aipids searched

- fixed RSV encoding
parent ce319ebf
No related branches found
No related tags found
No related merge requests found
......@@ -148,8 +148,15 @@ sub execute {
} @{$response->{hits}->{hits} };
my @headers = sort keys %{$result[0]};
my $aip_only = List::Util::none {$_ =~ m/^with/} keys %{ $opt };
if (!exists $opt->{output_format}) { $opt->{output_format} = 'output_as_rsv' ;}
if ($aip_only or ($opt->{output_format} eq 'output_as_csv') ) {
if (!exists $opt->{output_format}) {
if ($aip_only) {
$opt->{output_format} = 'output_as_csv'
} else {
$opt->{output_format} = 'output_as_rsv';
}
}
if ($opt->{output_format} eq 'output_as_csv') {
say join(",", @headers);
say join("\n", map {
my $line = $_;
......@@ -162,10 +169,15 @@ sub execute {
);
} elsif ($opt->{output_format} eq 'output_as_rsv') {
binmode(STDOUT, ':bytes');
print join(CHR_VALUE_TERMINATOR, @headers);
print CHR_ROW_TERMINATOR;
print join(CHR_ROW_TERMINATOR, map { join(CHR_VALUE_TERMINATOR,values %{ $_ }); } @result);
print join(CHR_VALUE_TERMINATOR, @headers).CHR_VALUE_TERMINATOR;
print CHR_ROW_TERMINATOR;
print join("", map {
my $line = $_;
my $res_line = join("", map { $line->{$_}.CHR_VALUE_TERMINATOR } @headers
);
$res_line.CHR_ROW_TERMINATOR;
} @result
);
binmode(STDOUT, ':encoding(UTF-8)');
} elsif ($opt->{output_format} eq 'output_as_raw') {
say np($response);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment