From eb95cd82ca4c527d86462ae8a12f62d8dd09f862 Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <andreas.romeyke@slub-dresden.de> Date: Tue, 28 May 2024 13:50:54 +0200 Subject: [PATCH] - added global opts --- lib/SLUB/LZA/TA/Command/count.pm | 9 +++------ lib/SLUB/LZA/TA/Command/report.pm | 6 +++--- lib/SLUB/LZA/TA/Command/search.pm | 12 ++++-------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/SLUB/LZA/TA/Command/count.pm b/lib/SLUB/LZA/TA/Command/count.pm index e23db39..f81fba5 100644 --- a/lib/SLUB/LZA/TA/Command/count.pm +++ b/lib/SLUB/LZA/TA/Command/count.pm @@ -31,7 +31,8 @@ sub description { return "$description" } sub opt_spec { - return( + my @global_opts= SLUB::LZA::TA::common_global_opt_spec(); + my @local_opts = ( #["source|s=s" => "count based on string search in source metadata"], ["aip|a=s" => "count AIPs by given AIP id"], [ 'datemode' => hidden => { @@ -60,15 +61,11 @@ sub opt_spec { [ 'only-ldp', 'only if AIP is LDP funded' ], [ 'no-ldp', 'only if AIP is not LDP funded' ], ] } ], - [], - [], - [ 'help|h', 'print usage message and exit', { shortcircuit => 1 } ], - [ 'version|v', 'print version information', { shortcircuit => 1 } ], ); + return (@global_opts, [], @local_opts); } sub validate_args { my ($self, $opt, $args) = @_; - SLUB::LZA::TA::validate_global(@_); # no args allowed but options! $self->usage_error("No args allowed") if @$args; if (exists $opt->{creationdate}) { diff --git a/lib/SLUB/LZA/TA/Command/report.pm b/lib/SLUB/LZA/TA/Command/report.pm index 2424ea2..c27457a 100644 --- a/lib/SLUB/LZA/TA/Command/report.pm +++ b/lib/SLUB/LZA/TA/Command/report.pm @@ -42,7 +42,8 @@ sub description { return "$description" } sub opt_spec { - return ( + my @global_opts= SLUB::LZA::TA::common_global_opt_spec(); + my @local_opts = ( [ 'datemode' => hidden => { one_of => [ [ 'daily|d' => 'report based on last day'], @@ -68,9 +69,8 @@ sub opt_spec { [ 'with-ldp|l' => 'report with LDP'], [ 'workflow|w=s' => 'LZA internal workflow name (optional)'], [], - [ 'help|h', 'print usage message and exit', { shortcircuit => 1 } ], - [ 'version|v', 'print version information', { shortcircuit => 1 } ], ); + return (@global_opts, [], @local_opts); } sub validate_args { my ($self, $opt, $args) = @_; diff --git a/lib/SLUB/LZA/TA/Command/search.pm b/lib/SLUB/LZA/TA/Command/search.pm index 6ae5f90..9d0baae 100644 --- a/lib/SLUB/LZA/TA/Command/search.pm +++ b/lib/SLUB/LZA/TA/Command/search.pm @@ -45,7 +45,8 @@ sub description { return "$description" } sub opt_spec { - return ( + my @global_opts= SLUB::LZA::TA::common_global_opt_spec(); + my @local_opts = ( [ 'output-format' => hidden => { one_of => [ [ 'output-as-csv|C' => 'prints output as Comma Separated Values (CSV)' ], @@ -114,17 +115,13 @@ sub opt_spec { [ 'with-slubarchiv-sipversion' => 'also returns AIP slubarchiv-sipversion'], [ 'with-status' => 'also returns AIP state in AIS' ], [ 'with-title' => 'also returns AIP title' ], - [], - [ 'help|h', 'print usage message and exit', { shortcircuit => 1 } ], - [ 'version|v', 'print version information', { shortcircuit => 1 } ], ); + return (@global_opts, [], @local_opts); } sub validate_args { my ($self, $opt, $args) = @_; - # no args allowed but options! $self->usage_error("No args allowed") if @$args; - SLUB::LZA::TA::validate_global(@_); if (exists $opt->{creationdate}) { if ($opt->{creationdate} =~ m/^(\d{4})-(\d{2})-(\d{2})$/ ) { my $from_epoch = Date_to_Time($1, $2, $3, 0, 0, 0); @@ -208,13 +205,12 @@ sub execute { $SLUB::LZA::TA::config{elasticsearch_protocol}, $SLUB::LZA::TA::config{elasticsearch_host}, $SLUB::LZA::TA::config{elasticsearch_port}, - 'aips', # indexname + 'aips', # indexname $aips_query, # query_hash ref ); #p($aips_response); SLUB::LZA::TA::Output::print_results($aips_response, $opt); return 1; - } 1; -- GitLab