Changeset 10230


Ignore:
Timestamp:
2005-07-08T11:08:25+12:00 (19 years ago)
Author:
kjdon
Message:

now uses jeffrey's new parse2 parsing. also now accepts xxx.pm as plugin/classifier name

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

Legend:

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

    r7952 r10230  
    2727###########################################################################
    2828
     29use strict;
     30no strict 'subs'; # allow barewords (eg STDERR) as function arguments
    2931
    3032BEGIN {
     
    3840use classify;
    3941use util;
    40 use parsargv;
    4142use gsprintf;
    4243use printusage;
    4344
     45use parse2;
    4446
    4547my $arguments =
     
    4749    'desc' => "{classinfo.collect}",
    4850    'type' => "string",
     51    'deft' => "",
    4952    'reqd' => "no" },
    5053      { 'name' => "xml",
     
    7073}
    7174
    72 
    73 #  sub print_usage {
    74 #      print STDERR "\n";
    75 #      print STDERR "classinfo.pl: Prints information about a classifier.\n\n";
    76 #      print STDERR " usage: $0 [options] classifier\n\n";
    77 #      print STDERR " options:\n";
    78 #      print STDERR "  -collect collection-name  Giving a collection name will make classinfo.pl\n";
    79 #      print STDERR "                            look in collect/collection-name/perllib/classify\n";
    80 #      print STDERR "                            first. If the classifier is not found there it will\n";
    81 #      print STDERR "                            look in the general perllib/classify directory.\n\n";
    82 #      print STDERR "  -xml                      Produces the information in an xml form, without\n";
    83 #      print STDERR "                            'pretty' comments but with much more detail.\n\n";
    84 #      print STDERR "  -language language-code   Language to display classifer options in (eg. 'en_US'\n";
    85 #      print STDERR "                            specifies American English). Requires translations\n";
    86 #      print STDERR "                            of the option descriptions to exist in the\n";
    87 #      print STDERR "                            perllib/strings_language-code.rb file.\n";
    88 #  }
    89 
    90 
    9175sub main {
    9276    my $collect = "";
    9377    my $xml = 0;
    9478    my $listall = 0;
     79    my $language;
    9580
    96     # Parse command line
    97     if (!parsargv::parse(\@ARGV,
    98              q^collect/.*/^, \$collect,
    99              q^xml^, \$xml,
    100              q^listall^, \$listall,
    101              q^language/.*/^, \$language))
     81    my $hashParsingResult = {};
     82    my $blnParseFailed = "false";
     83    # general options available to all plugins
     84    my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
     85    # If there are more than one argument left after parsing, it mean user input too many arguments.
     86    # Error occoured  will return 0
     87    if($intArgLeftinAfterParsing > 1)
    10288    {
    103     &PrintUsage::print_txt_usage($options, "{classinfo.params}", 1);
     89    &PrintUsage::print_txt_usage($options, "{classinfo.params}");
    10490    die "\n";
    10591    }
    10692
     93    foreach my $strVariable (keys %$hashParsingResult)
     94    {
     95    eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
     96    }
    10797    # If $language has been specified, load the appropriate resource bundle
    10898    # (Otherwise, the default resource bundle will be loaded automatically)
     
    113103    # Get classifier
    114104    my $classifier = shift (@ARGV);
     105    $classifier =~ s/\.pm$//; # allow xxx.pm as the argument
     106   
    115107    if (($listall == 0) && (!defined $classifier || $classifier eq "")) {
    116108    &gsprintf(STDERR, "{classinfo.no_classifier_name}\n\n");
  • trunk/gsdl/bin/script/pluginfo.pl

    r9375 r10230  
    4141use plugin;
    4242use util;
    43 use parsargv;
    4443use gsprintf;
    4544use printusage;
    4645
     46use parse2;
    4747
    4848my $arguments =
     
    7878    my $xml = 0;
    7979    my $listall = 0;
    80 
     80   
    8181    my ($language, $encoding);
    8282
    83     if (!parsargv::parse(\@ARGV,
    84              q^collect/.*/^, \$collect,
    85              q^xml^, \$xml,
    86              q^listall^, \$listall,
    87              q^language/.*/^, \$language))
     83    my $hashParsingResult = {};
     84    my $blnParseFailed = "false";
     85    # general options available to all plugins
     86    my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
     87    # If there are more than one argument left after parsing, it mean user input too many arguments.
     88    # Error occoured  will return 0
     89    if($intArgLeftinAfterParsing > 1)
    8890    {
    89     PrintUsage::print_txt_usage($options, "{pluginfo.params}", 1);
     91    &PrintUsage::print_txt_usage($options, "{pluginfo.params}");
    9092    die "\n";
     93    }
     94
     95    foreach my $strVariable (keys %$hashParsingResult)
     96    {
     97    eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
    9198    }
    9299
     
    114121
    115122    my $plugin = shift (@ARGV);
     123    $plugin =~ s/\.pm$//; # allow xxxPlug.pm as the argument
     124   
    116125    if (($listall == 0) && (!defined $plugin || $plugin eq "")) {
    117126    gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
Note: See TracChangeset for help on using the changeset viewer.