Skip to content
Snippets Groups Projects
Commit 52d5df4e authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- added more argument checks

- improved readability
parent cc013558
No related branches found
No related tags found
No related merge requests found
...@@ -59,20 +59,20 @@ my $man; ...@@ -59,20 +59,20 @@ my $man;
our $VERSION = '1.1'; our $VERSION = '1.1';
GetOptions( GetOptions(
"IE_directory=s" => \$directory, "IE_directory=s" => \$directory, # required
"ppn=s" => \$ppn, "ppn=s" => \$ppn, # semi-optional
"noppn=s" => \$noppn, "noppn=s" => \$noppn, # semi-optional
"SIP_output_path=s" => \$output, "SIP_output_path=s" => \$output, # required
"as_zip" => \$as_zip, "as_zip" => \$as_zip, # optional, default: do not zip
"url=s" => \$url, "url=s" => \$url, # optional, default: SWB Online-Katalog
"external_id=s" => \$external_id, "external_id=s" => \$external_id, # required
"external_workflow=s" => \$external_workflow, "external_workflow=s" => \$external_workflow, # required
"external_ISIL=s" => \$external_isil, "external_ISIL=s" => \$external_isil, # optional, default: no ISIL
"external_value_descr=s" => \$external_value_descr, "external_value_descr=s" => \$external_value_descr, # required
"external_conservation_flag" => \$external_conservation_flag, "external_conservation_flag" => \$external_conservation_flag, # optional, default: no special conservation
"debug" => \$with_debug, "debug" => \$with_debug, # optional
"help|?" => \$help, "help|?" => \$help, # optional
"man" => \$man, "man" => \$man, # optional
) or pod2usage(2); ) or pod2usage(2);
if ($help) { pod2usage(1); } if ($help) { pod2usage(1); }
...@@ -84,11 +84,11 @@ if (!defined $output) { confess (" you need to specify an output path, where the ...@@ -84,11 +84,11 @@ if (!defined $output) { confess (" you need to specify an output path, where the
if ($output !~ m#^/#) { confess("you need to specify an output path using absoluet paths, $!"); } if ($output !~ m#^/#) { confess("you need to specify an output path using absoluet paths, $!"); }
if (!defined $url) { $url = "http://swb.bsz-bw.de/sru/DB=2.1/username=/password=/";} if (!defined $url) { $url = "http://swb.bsz-bw.de/sru/DB=2.1/username=/password=/";}
if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; } if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; }
# additional checks
if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); } if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); }
if ($directory !~ m#^/#) { confess("you need to specify an IE directory using absoluet paths, $!"); } if ($directory !~ m#^/#) { confess("you need to specify an IE directory using absoluet paths, $!"); }
#if (! -d $output) { confess("you need to specify an output path, where the SIP will be stored, $!"); } if ($external_id !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); }
if ($external_workflow !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); }
if (!$external_value_descr) { confess("you need to specify a external value description (reason for archiving)"); }
#=============================================================================== #===============================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment