Changeset 7952


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.

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

Legend:

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

    r6966 r7952  
    5252    'type' => "flag",
    5353    'reqd' => "no" },
     54      { 'name' => "listall",
     55    'desc' => "{scripts.listall}",
     56    'type' => "flag",
     57    'reqd' => "no" },
    5458      { 'name' => "language",
    5559    'desc' => "{scripts.language}",
     
    8892    my $collect = "";
    8993    my $xml = 0;
     94    my $listall = 0;
    9095
    9196    # Parse command line
     
    9398             q^collect/.*/^, \$collect,
    9499             q^xml^, \$xml,
     100             q^listall^, \$listall,
    95101             q^language/.*/^, \$language))
    96102    {
     
    107113    # Get classifier
    108114    my $classifier = shift (@ARGV);
    109     if (!defined $classifier || $classifier eq "") {
     115    if (($listall == 0) && (!defined $classifier || $classifier eq "")) {
    110116    &gsprintf(STDERR, "{classinfo.no_classifier_name}\n\n");
    111117    &PrintUsage::print_txt_usage($options, "{classinfo.params}", 1);
     
    120126    }
    121127 
    122     #my $classinfo = &classify::load_classifiers ([[$classifier]]);
    123     #my $classobj = shift @$classinfo;
    124     my $classobj = &classify::load_classifier_for_info ($classifier);
    125     if ($xml) {
    126         $classobj->print_xml_usage();
     128    if ($listall) {
     129    my $class_dir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib","classify");
     130   
     131    if (!opendir (INDIR, $class_dir)) {
     132        print STDERR "classinfo.pl: could not open directory $class_dir\n";
     133    } else {
     134        my @class_list = grep (/\.pm$/, readdir (INDIR));
     135        closedir (INDIR);
     136
     137        if ($xml) {
     138        my $num_class = scalar(@class_list);
     139
     140        print STDERR "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     141        print STDERR "<!DOCTYPE ClassifyList [\n";
     142        print STDERR "  <!ELEMENT ClassifyList (ClassifyName*)>\n";
     143        print STDERR "  <!ELEMENT ClassifyName (#PCDATA)>\n";
     144        print STDERR "  <!ATTLIST ClassifyList\n";
     145        print STDERR "            length CDATA #REQUIRED>\n";
     146        print STDERR "]>\n";
     147
     148        print STDERR "<ClassifyList length=\"$num_class\">\n";
     149        map { print STDERR "  <ClassifyName>$_</ClassifyName>\n"; } @class_list;
     150        print STDERR "</ClassifyList>\n";
     151
     152        }
     153        else {
     154        print STDERR join(" ",@class_list), "\n";
     155        }
     156    }
     157
    127158    }
    128159    else {
    129     &gsprintf(STDERR, "\n{classinfo.passing_options}\n\n");
    130     &gsprintf(STDERR, "{classinfo.option_types}:\n\n");
    131     &gsprintf(STDERR, "{classinfo.specific_options}\n\n");
    132     &gsprintf(STDERR, "{classinfo.general_options}\n\n");
    133     &gsprintf(STDERR, "$classifier {classinfo.info}:\n\n");
    134 
    135     $classobj->print_txt_usage();
     160    my $classobj = &classify::load_classifier_for_info ($classifier);
     161    if ($xml) {
     162        $classobj->print_xml_usage();
     163    }
     164    else {
     165        &gsprintf(STDERR, "\n{classinfo.passing_options}\n\n");
     166        &gsprintf(STDERR, "{classinfo.option_types}:\n\n");
     167        &gsprintf(STDERR, "{classinfo.specific_options}\n\n");
     168        &gsprintf(STDERR, "{classinfo.general_options}\n\n");
     169        &gsprintf(STDERR, "$classifier {classinfo.info}:\n\n");
     170       
     171        $classobj->print_txt_usage();
     172    }
    136173    }
    137174}
  • 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.