From 1725d1bc85ae2da1487c338f8b632df582bf7eea Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Tue, 28 May 2024 11:24:10 +0200
Subject: [PATCH] - use global opts - fixed missed mandatory parameter check

---
 lib/SLUB/LZA/TA/Command/init.pm | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/SLUB/LZA/TA/Command/init.pm b/lib/SLUB/LZA/TA/Command/init.pm
index d14f1d9..990df25 100644
--- a/lib/SLUB/LZA/TA/Command/init.pm
+++ b/lib/SLUB/LZA/TA/Command/init.pm
@@ -14,18 +14,16 @@ use namespace::autoclean -except => qr{^SLUB::LZA::TA::.*};
 sub abstract { return "Initialize $0";}
 sub description { return "Initialize $0, preparing config file using given options"}
 sub opt_spec {
-    #my $common_global_opts= SLUB::LZA::TA::global_opt_spec();
+    my @global_opts= grep {
+        defined $_->[0]
+            and $_->[0] !~ m/^(elasticsearch-(host|port))|(http-only)/;
+    } SLUB::LZA::TA::common_global_opt_spec();
     my @local_opts = (
-        [ "help|h" => "this usage screen" ],
-        [ "verbose|v" => "enable verbose output" ],
-        [],
         [ "elasticsearch-host|e=s" => "host adress of Archivematica's ElasticSearch (mandatory)" ],
         [ "elasticsearch-port|E=s" => "port of Archivematica's ElasticSearch", { default => 9200 } ],
         [ "http-only" => "use HTTP instead HTTPS" ],
     );
-        #[ "logdir|l=s" => "logdir where Archivematica stores it server log files", {required => 1}],
-    # return ($global_opts, $local_opts);
-    return (@local_opts);
+    return (@global_opts, [], @local_opts);
 }
 sub validate_args {
     my ($self, $opt, $args) = @_;
@@ -33,7 +31,7 @@ sub validate_args {
     $self->usage_error("No args allowed") if @$args;
     $self->usage_error("Missed mandatory parameter '--elasticsearch-host'") if (
         !exists($opt->{elasticsearch_host})
-        and exists($opt->{help})
+        and !exists($opt->{help})
     );
     return 1;
 }
-- 
GitLab