[1244] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | ###########################################################################
|
---|
| 4 | #
|
---|
| 5 | # pluginfo.pl --
|
---|
| 6 | # A component of the Greenstone digital library software
|
---|
| 7 | # from the New Zealand Digital Library Project at the
|
---|
| 8 | # University of Waikato, New Zealand.
|
---|
| 9 | #
|
---|
| 10 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 11 | #
|
---|
| 12 | # This program is free software; you can redistribute it and/or modify
|
---|
| 13 | # it under the terms of the GNU General Public License as published by
|
---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | # (at your option) any later version.
|
---|
| 16 | #
|
---|
| 17 | # This program is distributed in the hope that it will be useful,
|
---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | # GNU General Public License for more details.
|
---|
| 21 | #
|
---|
| 22 | # You should have received a copy of the GNU General Public License
|
---|
| 23 | # along with this program; if not, write to the Free Software
|
---|
| 24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | #
|
---|
| 26 | ###########################################################################
|
---|
| 27 |
|
---|
| 28 | # This program will print info about a plugin
|
---|
| 29 |
|
---|
[3541] | 30 | # @revision 09/05/02 Added XML usage information flag - John Thompson
|
---|
| 31 |
|
---|
[1244] | 32 | BEGIN {
|
---|
| 33 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
| 34 | die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
|
---|
| 35 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
[5882] | 36 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
|
---|
[1244] | 37 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | use plugin;
|
---|
| 41 | use util;
|
---|
| 42 | use parsargv;
|
---|
[5606] | 43 | use gsprintf;
|
---|
| 44 | use printusage;
|
---|
[1244] | 45 |
|
---|
[5606] | 46 |
|
---|
| 47 | my $arguments =
|
---|
| 48 | [ { 'name' => "collect",
|
---|
| 49 | 'desc' => "{pluginfo.collect}",
|
---|
| 50 | 'type' => "string",
|
---|
| 51 | 'reqd' => "no" },
|
---|
| 52 | { 'name' => "xml",
|
---|
| 53 | 'desc' => "{scripts.xml}",
|
---|
| 54 | 'type' => "flag",
|
---|
| 55 | 'reqd' => "no" },
|
---|
| 56 | { 'name' => "language",
|
---|
| 57 | 'desc' => "{scripts.language}",
|
---|
| 58 | 'type' => "string",
|
---|
| 59 | 'reqd' => "no" } ];
|
---|
| 60 |
|
---|
| 61 | my $options = { 'name' => "pluginfo.pl",
|
---|
| 62 | 'desc' => "{pluginfo.desc}",
|
---|
| 63 | 'args' => $arguments };
|
---|
| 64 |
|
---|
[6921] | 65 | sub gsprintf
|
---|
[5606] | 66 | {
|
---|
[6921] | 67 | return &gsprintf::gsprintf(@_);
|
---|
[1244] | 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | sub main {
|
---|
| 72 | my $collect = "";
|
---|
[4749] | 73 | my $xml = 0;
|
---|
[4873] | 74 | my $language = ""; # Will display in the default language if not set
|
---|
[1244] | 75 |
|
---|
[4873] | 76 | if (!parsargv::parse(\@ARGV,
|
---|
| 77 | q^collect/.*/^, \$collect,
|
---|
| 78 | q^xml^, \$xml,
|
---|
| 79 | q^language/.*/^, \$language))
|
---|
[4749] | 80 | {
|
---|
[6921] | 81 | &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1);
|
---|
[4749] | 82 | die "\n";
|
---|
| 83 | }
|
---|
[3541] | 84 |
|
---|
[1244] | 85 | my $plugin = shift (@ARGV);
|
---|
| 86 | if (!defined $plugin || $plugin eq "") {
|
---|
[6921] | 87 | &gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
|
---|
| 88 | &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1);
|
---|
[4749] | 89 | die "\n";
|
---|
[1244] | 90 | }
|
---|
| 91 |
|
---|
| 92 | if ($collect ne "") {
|
---|
[4749] | 93 | $ENV{'GSDLCOLLECTDIR'} = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collect);
|
---|
[1244] | 94 | } else {
|
---|
[4749] | 95 | $ENV{'GSDLCOLLECTDIR'} = $ENV{'GSDLHOME'};
|
---|
[1244] | 96 | }
|
---|
| 97 |
|
---|
[4749] | 98 | my $pluginfo = &plugin::load_plugins ([[$plugin]]);
|
---|
| 99 | my $plugobj = shift @$pluginfo;
|
---|
[1244] | 100 |
|
---|
[4873] | 101 | if ($xml) {
|
---|
| 102 | $plugobj->print_xml_usage($language);
|
---|
[4749] | 103 | }
|
---|
| 104 | else {
|
---|
[6921] | 105 | &gsprintf(STDERR, "\n$plugin {pluginfo.info}:\n\n");
|
---|
| 106 | &gsprintf(STDERR, "{pluginfo.passing_options}\n\n");
|
---|
| 107 | &gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
|
---|
| 108 | &gsprintf(STDERR, "{pluginfo.specific_options}\n\n");
|
---|
| 109 | &gsprintf(STDERR, "{pluginfo.general_options}\n\n");
|
---|
[4749] | 110 |
|
---|
[4873] | 111 | $plugobj->print_txt_usage($language);
|
---|
[5638] | 112 | }
|
---|
| 113 | }
|
---|
[4749] | 114 |
|
---|
| 115 |
|
---|
[5638] | 116 | # this causes us to automatically send output to a pager, if one is
|
---|
| 117 | # set, AND our output is going to a terminal
|
---|
| 118 | # active state perl on windows doesn't do open(handle, "-|");
|
---|
| 119 | if ($ENV{'GSDLOS'} !~ /windows/ && -t STDOUT) {
|
---|
| 120 | my $pager = $ENV{"PAGER"};
|
---|
| 121 | if (! $pager) {$pager="(less || more)"}
|
---|
| 122 | $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
|
---|
| 123 | if (!defined $pid) {
|
---|
[6921] | 124 | &gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
|
---|
[5638] | 125 | } else {
|
---|
| 126 | if ($pid != 0) { # parent (ie forking) process. child gets 0
|
---|
| 127 | exec ($pager);
|
---|
| 128 | }
|
---|
[4749] | 129 | }
|
---|
[5638] | 130 | open(STDERR,">&STDOUT"); # so it's easier to pipe output
|
---|
[1244] | 131 | }
|
---|
| 132 |
|
---|
[5606] | 133 |
|
---|
| 134 | &main ();
|
---|