Ignore:
Timestamp:
2012-07-17T15:17:30+12:00 (12 years ago)
Author:
kjdon
Message:

adding in support for plugins knowing what version of greenstone (2/3) they are running in. gs_version now passed in when loading plugins, and '-gs_version 2/3' will be added to input args. base plugin class PrintInfo defines the gs_version arg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/PrintInfo.pm

    r24347 r25957  
    4747use printusage;
    4848
    49 my $arguments = [];
     49my $arguments = [
     50    { 'name' => "gs_version",
     51      'desc' => "{PrintInfo.gs_version}",
     52      'type' => "string",
     53      'reqd' => "no",
     54      'hiddengli' => "yes" }
     55
     56];
    5057
    5158my $options = { 'name'     => "PrintInfo",
     
    6269    my $plugin_name = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class;
    6370
    64     if ($plugin_name eq $class) {
     71   if ($plugin_name eq $class) {
    6572    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
    6673    push(@{$hashArgOptLists->{"OptList"}},$options);
    67     }
     74   }
    6875    my $self = {};
    6976    $self->{'outhandle'} = STDERR;
    7077    $self->{'option_list'} = $hashArgOptLists->{"OptList"};
    7178    $self->{"info_only"} = 0;
    72 
     79    $self->{'gs_version'} = "2";
    7380    # Check if gsdlinfo is in the argument list or not - if it is, don't parse
    74     # the args, just return the object. 
     81    # the args, just return the object.
     82    # gsdlinfo must come before gs_version. both are set by plugin.pm
     83    my $v=0;
    7584    foreach my $strArg (@{$args})
    7685    {
    77     if($strArg eq "-gsdlinfo")
     86    if ($v) {
     87        $self->{'gs_version'} = $strArg;
     88        last;
     89    }
     90    elsif($strArg eq "-gsdlinfo")
    7891    {
    7992        $self->{"info_only"} = 1;
    80         return bless $self, $class;
    81     }
    82     }
    83    
     93        #return bless $self, $class;
     94    }
     95    elsif ($strArg eq "-gs_version") {
     96        $v = 1;     
     97    }
     98    }
     99
     100    if ($self->{"info_only"}) {
     101    return bless $self, $class;
     102    }
    84103    if (defined $auxiliary) { # don't parse the args here
    85104    return bless $self, $class;
     105    }
     106
     107    # now that we are passed printing out info, we do need to add in this class's options so that they are available for parsing.
     108    if ($plugin_name ne $class) {
     109    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
     110    push(@{$hashArgOptLists->{"OptList"}},$options);
    86111    }
    87112
Note: See TracChangeset for help on using the changeset viewer.