Changeset 10215


Ignore:
Timestamp:
2005-07-06T15:20:33+12:00 (19 years ago)
Author:
kjdon
Message:

added Jeffrey's changes for parsing arguments - now all parsing is done from the arguments structure, not using parsarg

Location:
trunk/gsdl/bin/script
Files:
2 edited

Legend:

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

    r9903 r10215  
    4545use gsprintf;
    4646use printusage;
     47use parse2;
    4748
    4849my $mode_list =
     
    7980    'desc' => "{buildcol.collectdir}",
    8081    'type' => "string",
    81     'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
     82    # parsearg left "" as default
     83    #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
    8284    'reqd' => "no",
    8385        'hiddengli' => "yes" },
     
    9597    'desc' => "{buildcol.faillog}",
    9698    'type' => "string",
    97     'deft' => &util::filename_cat("<collectdir>", "colname", "etc", "fail.log"),
     99    # parsearg left "" as default
     100    #'deft' => &util::filename_cat("<collectdir>", "colname", "etc", "fail.log"),
    98101    'reqd' => "no",
    99102    'modegli' => "4" },
     
    122125    'type' => "enum",
    123126    'list' => $mode_list,
    124     'deft' => "all",
     127    # parsearg left "" as default
     128#   'deft' => "all",
    125129    'reqd' => "no",
    126130    'modegli' => "4" },
     
    144148    'desc' => "{buildcol.verbosity}",
    145149    'type' => "int",
    146     'deft' => "2",
    147     'reqd' => "no",
    148     'modegli' => "4" } ];
     150    # parsearg left "" as default
     151    #'deft' => "2",
     152    'reqd' => "no",
     153    'modegli' => "4" },
     154      { 'name' => "gli",
     155    'desc' => "",
     156    'type' => "flag",
     157    'reqd' => "no",
     158    'hiddengli' => "yes" },
     159      { 'name' => "xml",
     160    'desc' => "",
     161    'type' => "flag",
     162    'reqd' => "no",
     163    'hiddengli' => "yes" } ];
    149164
    150165my $options = { 'name' => "buildcol.pl",
     
    168183    $no_strip_html, $no_text, $faillog, $gli);
    169184
    170     # ***** 11-04-03 - John Thompson *****
    171185    my $xml = 0;
    172     # ************************************
    173 
    174     # note that no defaults are passed for most options as they're set
    175     # later (after we check the collect.cfg file)
    176     if (!parsargv::parse(\@ARGV,
    177              'language/.*/', \$language,
    178              'verbosity/\d+/', \$verbosity,
    179              'archivedir/.*/', \$archivedir,
    180              'cachedir/.*/', \$cachedir,  # UNDOCUMENTED
    181              'builddir/.*/', \$builddir,
    182              'maxdocs/^\-?\d+/', \$maxdocs,
    183              'debug', \$debug,
    184              'mode/^(all|compress_text|build_index|infodb)$/', \$mode,
    185              'index/.*/', \$indexname,
    186              'no_text', \$no_text,
    187              'keepold', \$keepold,
    188              'remove_empty_classifications', \$remove_empty_classifications,
    189              'create_images', \$create_images,
    190              'collectdir/.*/', \$collectdir,
    191              'out/.*/STDERR', \$out,
    192              'no_strip_html', \$no_strip_html,
    193              'faillog/.*/', \$faillog,
    194              'gli', \$gli,
    195              q^xml^, \$xml)) {
     186
     187    my $hashParsingResult = {};
     188    my $blnParseFailed = "false";
     189    # general options available to all plugins
     190    $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
     191    # If there are more than one argument left after parsing, it mean user input too many arguments.
     192    # Error occoured  will return 0
     193    if($intArgLeftinAfterParsing != 1)
     194    {
     195    $blnParseFailed = "true";
     196    }
     197    if($blnParseFailed eq "true")
     198    {
     199    print "";
    196200    &PrintUsage::print_txt_usage($options, "{buildcol.params}");
    197201    die "\n";
     202    }
     203    foreach my $strVariable (keys %$hashParsingResult)
     204    {
     205    eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
    198206    }
    199207
     
    410418    $builder->set_strip_html(0);
    411419    }
    412 
     420   
    413421    if ($mode =~ /^all$/i) {
    414422    $builder->compress_text($textindex);
  • trunk/gsdl/bin/script/import.pl

    r10162 r10215  
    4949use gsprintf 'gsprintf';
    5050use printusage;
     51use parse2;
    5152
    5253my $oidtype_list =
     
    8586    'desc' => "{import.collectdir}",
    8687    'type' => "string",
    87     'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
     88    # parsearg left "" as default
     89    #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
     90    'deft' => "",
    8891    'reqd' => "no",
    8992        'hiddengli' => "yes" },
     
    9699    'desc' => "{import.faillog}",
    97100    'type' => "string",
    98     'deft' => &util::filename_cat("&lt;collectdir&gt;", "colname", "etc", "fail.log"),
     101    # parsearg left "" as default
     102    #'deft' => &util::filename_cat("&lt;collectdir&gt;", "colname", "etc", "fail.log"),
     103    'deft' => "",
    99104    'reqd' => "no",
    100105        'modegli' => "4" },
     
    129134    'type' => "int",
    130135    'reqd' => "no",
     136    # parsearg left "" as default
     137    #'deft' => "-1",
    131138    'range' => "1,",
    132139    'modegli' => "1" },
     
    135142    'type' => "enum",
    136143    'list' => $oidtype_list,
    137     'deft' => "hash",
     144    # parsearg left "" as default
     145    #'deft' => "hash",
    138146    'reqd' => "no",
    139147    'modegli' => "3" },
     
    158166      { 'name' => "sortmeta",
    159167    'desc' => "{import.sortmeta}",
    160     'type' => "metadatum",
     168#   'type' => "metadatum",
     169    'type' => "string",
    161170    'reqd' => "no",
    162171    'modegli' => "3" },
     
    182191    'desc' => "{import.verbosity}",
    183192    'type' => "int",
    184     'range' => "0,3",
    185     'deft' => "2",
    186     'reqd' => "no",
    187     'modegli' => "4" }];
     193    'range' => "0,",
     194    # parsearg left "" as default
     195    #'deft' => "2",
     196    'reqd' => "no",
     197    'modegli' => "4" },
     198      { 'name' => "gli",
     199    'desc' => "",
     200    'type' => "flag",
     201    'reqd' => "no",
     202    'hiddengli' => "yes" },
     203      { 'name' => "xml",
     204    'desc' => "",
     205    'type' => "flag",
     206    'reqd' => "no",
     207    'hiddengli' => "yes" }];
    188208
    189209my $options = { 'name' => "import.pl",
     
    203223    $archive_info, $processor, $out, $faillog, $collectdir, $gli);
    204224
    205     # ***** 11-04-03 - John Thompson *****
    206225    my $xml = 0;
    207     # ************************************
     226
    208227    my $service = "import";
    209228
    210     # note that no defaults are passed for most options as they're set
    211     # later (after we check the collect.cfg file)
    212     if (!parsargv::parse(\@ARGV,
    213              'language/.*/', \$language,
    214              'verbosity/\d+/', \$verbosity,
    215              'importdir/.*/', \$importdir,
    216              'archivedir/.*/', \$archivedir,
    217              'keepold', \$keepold,
    218              'removeold', \$removeold,
    219              'saveas/^(GA|METS|DSpace)$/GA', \$saveas,
    220              'version/.*/', \$version,
    221              'gzip', \$gzip,
    222              'groupsize/\d+/1', \$groupsize,
    223              'OIDtype/^(hash|incremental|assigned|dirname)$/', \$OIDtype,
    224              'sortmeta/.*/', \$sortmeta,
    225              'removeprefix/.*/', \$removeprefix,
    226              'removesuffix/.*/', \$removesuffix,
    227              'debug', \$debug,
    228              'maxdocs/^\-?\d+/', \$maxdocs,
    229              'collectdir/.*/', \$collectdir,
    230              'out/.*/STDERR', \$out,
    231              'statsfile/.*/STDERR', \$statsfile,
    232              'faillog/.*/', \$faillog,
    233              'gli', \$gli,
    234              q^xml^, \$xml)) {
     229    my $hashParsingResult = {};
     230    my $blnParseFailed = "false";
     231    # general options available to all plugins
     232    $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
     233    # If there are more than one argument left after parsing, it mean user input too many arguments.
     234    # Error occoured  will return 0
     235    if($intArgLeftinAfterParsing != 1)
     236    {
     237    $blnParseFailed = "true";
     238    }
     239    if($blnParseFailed eq "true")
     240    {
    235241    &PrintUsage::print_txt_usage($options, "{import.params}");
    236242    die "\n";
     243    }
     244    foreach my $strVariable (keys %$hashParsingResult)
     245    {
     246    eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
    237247    }
    238248
     
    277287    (&gsprintf(STDERR, "{import.cannot_open_fail_log}\n", $faillog) && die);
    278288
     289   
    279290    my $faillogname = $faillog;
    280291    $faillog = 'import::FAILLOG';
     
    287298    $sortmeta = undef;
    288299    }
    289 
    290300    # dynamically load 'docsave' module so it can pick up on a collection
    291301    # specific docsave.pm is specified.
     
    382392        $gli = 1;
    383393    }
     394   
    384395
    385396    # global plugin stuff
Note: See TracChangeset for help on using the changeset viewer.