Ignore:
Timestamp:
2006-08-24T16:17:35+12:00 (18 years ago)
Author:
kjdon
Message:

changed parse2::parse so that it returns -1 on error, 0 on success, or if allow_extra_options is specified, then on success returns the number of args left over. allowed the use of -h to print the usage for all scripts

File:
1 edited

Legend:

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

    r11683 r12545  
    8585
    8686    my $hashParsingResult = {};
    87     my $blnParseFailed = "false";
    8887    # general options available to all plugins
    8988    my $unparsed_args = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
    90 
     89    # parse returns -1 if an error occurred
     90    if ($unparsed_args == -1) {
     91   
     92    PrintUsage::print_txt_usage($options, "{pluginfo.params}");
     93    die "\n";
     94    }
     95   
    9196    foreach my $strVariable (keys %$hashParsingResult)
    9297    {
     
    121126    }
    122127
    123     # If there are more than one argument left after parsing, it mean user input too many arguments.
    124     # Error occoured  will return 0
    125     if( $unparsed_args > 1 or (@ARGV && $ARGV[0] =~ /^\-+h/) )
     128    # If there is not exactly 1 argument left (plugin name), then the arguments were wrong
     129    # Or if the user specified -h, then we output the usage also
     130    if( $unparsed_args != 1 || (@ARGV && $ARGV[0] =~ /^\-+h/) )
    126131    {
    127     PrintUsage::print_txt_usage($options, "{pluginfo.params}");
    128     die "\n";
    129     }
    130 
     132    PrintUsage::print_txt_usage($options, "{pluginfo.params}"); 
     133        die "\n";
     134    }
     135   
    131136    my $plugin = shift (@ARGV);
    132137    if (defined $plugin) {
Note: See TracChangeset for help on using the changeset viewer.