Ignore:
Timestamp:
2004-08-16T15:55:22+12:00 (20 years ago)
Author:
davidb
Message:

Script extended to support '-listall' option which prints out all the
plugins/classifiers it knows about.

File:
1 edited

Legend:

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

    r6994 r7952  
    5555    'type' => "flag",
    5656    'reqd' => "no" },
     57      { 'name' => "listall",
     58    'desc' => "{scripts.listall}",
     59    'type' => "flag",
     60    'reqd' => "no" },
    5761      { 'name' => "language",
    5862    'desc' => "{scripts.language}",
     
    7377    my $collect = "";
    7478    my $xml = 0;
     79    my $listall = 0;
    7580
    7681    my ($language, $encoding);
     
    7984             q^collect/.*/^, \$collect,
    8085             q^xml^, \$xml,
     86             q^listall^, \$listall,
    8187             q^language/.*/^, \$language))
    8288    {
     
    107113
    108114    my $plugin = shift (@ARGV);
    109     if (!defined $plugin || $plugin eq "") {
     115    if (($listall == 0) && (!defined $plugin || $plugin eq "")) {
    110116    gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
    111117    PrintUsage::print_txt_usage($options, "{pluginfo.params}", 1);
     
    119125    }
    120126
    121     my $pluginfo = &plugin::load_plugins ([[$plugin]]);
    122     my $plugobj = shift @$pluginfo;
     127    if ($listall) {
     128    my $plugin_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","plugins");
     129   
     130    if (!opendir (INDIR, $plugin_dir)) {
     131        print STDERR "pluginfo.pl: could not open directory $plugin_dir\n";
     132    } else {
     133        my @plugin_list = grep (/Plug\.pm$/, readdir (INDIR));
     134        closedir (INDIR);
    123135
    124     if ($xml) {
    125         $plugobj->print_xml_usage();
     136
     137        if ($xml) {
     138        my $num_plugins = scalar(@plugin_list);
     139
     140        print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     141        print STDERR "<!DOCTYPE PluginList [\n";
     142        print STDERR "  <!ELEMENT PluginList (PluginName*)>\n";
     143        print STDERR "  <!ELEMENT PlugName   (#PCDATA)>\n";
     144        print STDERR "  <!ATTLIST PluginList\n";
     145        print STDERR "            length CDATA #REQUIRED>\n";
     146        print STDERR "]>\n";
     147
     148        print STDERR "<PluginList length=\"$num_plugins\">\n";
     149        map { print STDERR "  <PluginName>$_</PluginName>\n"; } @plugin_list;
     150        print STDERR "</PluginList>\n";
     151
     152        }
     153        else {
     154        print STDERR join(" ",@plugin_list), "\n";
     155        }
     156    }
     157
    126158    }
    127159    else {
    128     gsprintf(STDERR, "\n{pluginfo.passing_options}\n\n");
    129     gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
    130     gsprintf(STDERR, "{pluginfo.specific_options}\n\n");
    131     gsprintf(STDERR, "{pluginfo.general_options}\n\n");
    132     gsprintf(STDERR, "$plugin {pluginfo.info}:\n\n");
    133160
    134     $plugobj->print_txt_usage();
     161    my $pluginfo = &plugin::load_plugins ([[$plugin]]);
     162    my $plugobj = shift @$pluginfo;
     163   
     164    if ($xml) {
     165        $plugobj->print_xml_usage();
     166    }
     167    else {
     168        gsprintf(STDERR, "\n{pluginfo.passing_options}\n\n");
     169        gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
     170        gsprintf(STDERR, "{pluginfo.specific_options}\n\n");
     171        gsprintf(STDERR, "{pluginfo.general_options}\n\n");
     172        gsprintf(STDERR, "$plugin {pluginfo.info}:\n\n");
     173       
     174        $plugobj->print_txt_usage();
     175    }
    135176    }
    136177}
Note: See TracChangeset for help on using the changeset viewer.