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 |
|
---|
30 | # @revision 09/05/02 Added XML usage information flag - John Thompson
|
---|
31 |
|
---|
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");
|
---|
36 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
|
---|
37 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
|
---|
38 | }
|
---|
39 |
|
---|
40 | use plugin;
|
---|
41 | use util;
|
---|
42 | use parsargv;
|
---|
43 | use gsprintf;
|
---|
44 | use printusage;
|
---|
45 |
|
---|
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 |
|
---|
65 | sub gsprintf
|
---|
66 | {
|
---|
67 | return &gsprintf::gsprintf(@_);
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | sub main {
|
---|
72 | my $collect = "";
|
---|
73 | my $xml = 0;
|
---|
74 | my $language = ""; # Will display in the default language if not set
|
---|
75 |
|
---|
76 | if (!parsargv::parse(\@ARGV,
|
---|
77 | q^collect/.*/^, \$collect,
|
---|
78 | q^xml^, \$xml,
|
---|
79 | q^language/.*/^, \$language))
|
---|
80 | {
|
---|
81 | &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1);
|
---|
82 | die "\n";
|
---|
83 | }
|
---|
84 |
|
---|
85 | my $plugin = shift (@ARGV);
|
---|
86 | if (!defined $plugin || $plugin eq "") {
|
---|
87 | &gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
|
---|
88 | &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1);
|
---|
89 | die "\n";
|
---|
90 | }
|
---|
91 |
|
---|
92 | if ($collect ne "") {
|
---|
93 | $ENV{'GSDLCOLLECTDIR'} = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collect);
|
---|
94 | } else {
|
---|
95 | $ENV{'GSDLCOLLECTDIR'} = $ENV{'GSDLHOME'};
|
---|
96 | }
|
---|
97 |
|
---|
98 | my $pluginfo = &plugin::load_plugins ([[$plugin]]);
|
---|
99 | my $plugobj = shift @$pluginfo;
|
---|
100 |
|
---|
101 | if ($xml) {
|
---|
102 | $plugobj->print_xml_usage($language);
|
---|
103 | }
|
---|
104 | else {
|
---|
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");
|
---|
110 |
|
---|
111 | $plugobj->print_txt_usage($language);
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 |
|
---|
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) {
|
---|
124 | &gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
|
---|
125 | } else {
|
---|
126 | if ($pid != 0) { # parent (ie forking) process. child gets 0
|
---|
127 | exec ($pager);
|
---|
128 | }
|
---|
129 | }
|
---|
130 | open(STDERR,">&STDOUT"); # so it's easier to pipe output
|
---|
131 | }
|
---|
132 |
|
---|
133 |
|
---|
134 | &main ();
|
---|