Changeset 10340


Ignore:
Timestamp:
2005-07-28T14:10:21+12:00 (19 years ago)
Author:
kjdon
Message:

use new parse2 arg parsing, added 'use strict'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/export.pl

    r10162 r10340  
    4141}
    4242
     43use strict;
     44no strict 'refs'; # allow filehandles to be variables and vice versa
     45no strict 'subs'; # allow barewords (eg STDERR) as function arguments
     46
    4347use arcinfo;
    4448use colcfg;
     
    4650use docprint;
    4751use util;
    48 use parsargv;
    4952use FileHandle;
    5053use gsprintf;
    5154use printusage;
     55use parse2;
     56
    5257
    5358my $oidtype_list =
     
    8489
    8590my $arguments =
    86     [ { 'name' => "exportdir",
     91    [
     92      $saveas_argument,
     93      { 'name' => "saveas_version",
     94    'desc' => "{export.saveas_version}",
     95    'type' => "string",
     96    'reqd' => "no" },
     97      { 'name' => "exportdir",
    8798    'desc' => "{export.exportdir}",
     99    'type' => "string",
     100    'reqd' => "no",
     101        'hiddengli' => "yes" },
     102      { 'name' => "importdir",
     103    'desc' => "{import.importdir}",
    88104    'type' => "string",
    89105    'reqd' => "no",
     
    107123    'desc' => "{export.faillog}",
    108124    'type' => "string",
    109     'deft' => &util::filename_cat("<collectdir>", "colname", "etc", "fail.log"),
     125    'deft' => "",
    110126    'reqd' => "no",
    111127        'modegli' => "4" },
    112       { 'name' => "importdir",
    113     'desc' => "{import.importdir}",
    114     'type' => "string",
    115     'reqd' => "no",
    116         'hiddengli' => "yes" },
    117128      { 'name' => "keepold",
    118129    'desc' => "{export.keepold}",
     
    120131    'reqd' => "no",
    121132        'hiddengli' => "yes" },
     133      { 'name' => "removeold",
     134    'desc' => "{export.removeold}",
     135    'type' => "flag",
     136    'reqd' => "no",
     137    'modegli' => "3" },
    122138      { 'name' => "language",
    123139    'desc' => "{scripts.language}",
     
    137153    'reqd' => "no",
    138154        'hiddengli' => "yes" },
    139       { 'name' => "removeold",
    140     'desc' => "{export.removeold}",
    141     'type' => "flag",
    142     'reqd' => "no",
    143     'modegli' => "3" },
    144       $saveas_argument,
    145155      { 'name' => "statsfile",
    146156    'desc' => "{export.statsfile}",
     
    155165    'deft' => "2",
    156166    'reqd' => "no",
    157     'modegli' => "4" } ];
     167    'modegli' => "4" },
     168      { 'name' => "gli",
     169    'desc' => "",
     170    'type' => "flag",
     171    'reqd' => "no",
     172    'hiddengli' => "yes" },
     173      { 'name' => "xml",
     174    'desc' => "{scripts.xml}",
     175    'type' => "flag",
     176    'reqd' => "no",
     177    'hiddengli' => "yes" }
     178      ];
    158179
    159180my $options = { 'name' => "export.pl",
     
    174195
    175196sub main {
    176     my ($verbosity, $importdir, $archivedir, $keepold, $listall,
    177     $removeold, $saveas, $version,
    178     $gzip, $groupsize, $OIDtype, $debug,
    179     $maxdocs, $collection, $configfilename,
    180     $pluginfo, $sortmeta,
    181     $export_info_filename, $statsfile,
    182     $export_info, $processor, $out, $faillog, $collectdir, $gli);
    183 
    184     # ***** 11-04-03 - John Thompson *****
     197    # params
     198    my ($language, $verbosity, $importdir, $exportdir, $keepold, $listall,
     199    $removeold, $saveas, $saveas_version, $debug,
     200    $maxdocs, $statsfile, $out, $faillog, $collectdir, $gli);
    185201    my $xml = 0;
    186     # ************************************
     202   
     203    # other vars
     204    my ($configfilename, $collection, $export_info_filename, $export_info, $processor, $pluginfo);
    187205    my $service = "export";
    188206
    189     # note that no defaults are passed for most options as they're set
    190     # later (after we check the collect.cfg file)
    191     if (!parsargv::parse(\@ARGV,
    192              'language/.*/', \$language,
    193              'verbosity/\d+/', \$verbosity,
    194              'importdir/.*/', \$importdir,
    195              'exportdir/.*/', \$exportdir,
    196              'listall', \$listall,
    197              'keepold', \$keepold,
    198              'removeold', \$removeold,
    199              'saveas/^(DSpace|METS|GA)$/METS', \$saveas,
    200              'version/.*/', \$version,
    201              'debug', \$debug,
    202              'maxdocs/^\-?\d+/', \$maxdocs,
    203              'collectdir/.*/', \$collectdir,
    204              'out/.*/STDERR', \$out,
    205              'statsfile/.*/STDERR', \$statsfile,
    206              'faillog/.*/', \$faillog,
    207              'gli', \$gli,
    208              q^xml^, \$xml)) {
    209     &PrintUsage::print_txt_usage($options, "{export.params}");
    210     die "\n";
    211     }
    212 
    213     $gzip = undef;
    214     $groupsize = 1;
    215     $OIDtype = undef;
    216     $sortmeta = undef;
     207    my $hashParsingResult = {};
     208    my $blnParseFailed = "false";
     209    # general options available to all plugins
     210    my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
     211    # can have more than one collection name, so don't check num args left   
     212    foreach my $strVariable (keys %$hashParsingResult)
     213    {
     214    eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
     215    }
     216
     217   
     218    # these are options used by other things - we just set default values
     219    # undef means will be set from config file if there
     220    my $gzip = undef;
     221    my $groupsize = 1;
     222    my $OIDtype = undef;
     223    my $sortmeta = undef;
    217224
    218225    my $explicit_exportdir = (defined $exportdir) ? 1 : 0;
     
    239246    }
    240247
     248    if (scalar(@ARGV) == 0) {
     249    &PrintUsage::print_txt_usage($options, "{export.params}");
     250    die "\n";
     251    }
     252
    241253    if ($gli) { # the gli wants strings to be in UTF-8
    242254    &gsprintf::output_strings_in_UTF8;
     
    418430        $processor->set_OIDtype ($OIDtype);
    419431        $processor->set_saveas ($saveas);
    420         $processor->set_saveas_version ($version);
     432        $processor->set_saveas_version ($saveas_version);
    421433        } else {
    422434        $processor = new docprint ();
     
    476488    $removeold = 0 if ($explicit_exportdir);
    477489
    478     }
     490    } # while processing ARGV
    479491   
    480492    &gsprintf($out, "\n");
Note: See TracChangeset for help on using the changeset viewer.