From afd71a54a13f59acc31198f40c787757984d0a00 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <art1@andreas-romeyke.de>
Date: Fri, 29 Oct 2021 19:34:02 +0200
Subject: [PATCH] - fixed perl critic warnings - added cli command for version
 - uses get_sip_version() now

---
 bin/slubsipbuilderbagit.pl | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl
index 9966f2e..91089ff 100644
--- a/bin/slubsipbuilderbagit.pl
+++ b/bin/slubsipbuilderbagit.pl
@@ -42,12 +42,7 @@
 
 use strict;
 use warnings;
-use utf8;
 
-# version of SIP,
-# see L<https://slubarchiv.slub-dresden.de/technische-standards-fuer-die-ablieferung-von-digitalen-dokumenten>,
-# document "SIP Spezifikation für automatischen Ingest SLUBArchiv (v2.0.1)" for details
-my $sipVersion='v2020.1';
 
 #===============================================================================
 
@@ -58,7 +53,7 @@ BEGIN{
     }
 }
 
-use utf8;
+use feature 'say';
 use SLUB::LZA::SIPBuilderBagIt;
 use DateTime::Format::ISO8601;
 use Getopt::Long;
@@ -109,7 +104,14 @@ GetOptions(
     "debug"                      => \$SLUB::LZA::SIPBuilderBagIt::with_debug, # optional
     "help|?"                     => \$help,                                   # optional
     "man"                        => \$man,                                    # optional
-    "print_sip_version"          => sub{ print "supported sip version is $sipVersion\n"; exit 1; }, # optional
+    "print_sip_version"          => sub {
+        say "supported sip version is " . SLUB::LZA::SIPBuilderBagIt::get_sip_version();
+        exit 1;
+    },                                                                        # optional
+    "version"                    => sub {
+        say "version is " . $SLUB::LZA::SIPBuilderBagIt::VERSION;
+        exit 1;
+    }
 ) or pod2usage(2);
 
 # help
@@ -151,8 +153,8 @@ if ((!defined $ppn && !defined $noppn) || (!defined $ppn && $noppn eq "") || (!d
 
 #########################################################>  bag-info.txt  <###############################################################################
 
-utf8::decode($sipVersion);
-push @addBagInfo, {'SLUBArchiv-sipVersion' => $sipVersion};
+
+push @addBagInfo, {'SLUBArchiv-sipVersion' => SLUB::LZA::SIPBuilderBagIt::get_sip_version()};
 # externalWorkflow
 if (!defined $externalWorkflow || $externalWorkflow eq "") {
     SLUB::LZA::SIPBuilderBagIt::print_scalar_data( "ERROR: you need to specify external workflow", "red");
@@ -337,6 +339,7 @@ Options:
         -add_meta_file=<file>           optional, can be repeated, additional meta files(absolute path!)
         -add_key_value=<"key:value">    optional, can be repeated, additional key value pairs for bag-info.txt
         -print_sip_version              optional, print the supported SIP version
+        -version                        version of sip builder itself
 
 =head1 EXAMPLES
 
-- 
GitLab