source: main/tags/2.40/gsdl/bin/script/classinfo.pl@ 21085

Last change on this file since 21085 was 4779, checked in by mdewsnip, 21 years ago

Tidied up the code for displaying usage text.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# classinfo.pl -- provide information about classifiers
6#
7# A component of the Greenstone digital library software
8# from the New Zealand Digital Library Project at the
9# University of Waikato, New Zealand.
10#
11# Copyright (C) 1999 New Zealand Digital Library Project
12#
13# This program is free software; you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation; either version 2 of the License, or
16# (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, write to the Free Software
25# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26#
27###########################################################################
28
29
30BEGIN {
31 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
32 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
33 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
34 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify");
35}
36
37use classify;
38use util;
39use parsargv;
40
41sub print_usage {
42 print STDERR "\n";
43 print STDERR "classinfo.pl: Prints information about a classifier.\n\n";
44 print STDERR " usage: $0 [options] classifier\n\n";
45 print STDERR " options:\n";
46 print STDERR " -collect collection-name Giving a collection name will make\n";
47 print STDERR " classinfo.pl look in collect/collection-name/perllib/classify\n";
48 print STDERR " first. If it doesn't find it there it will look in the general\n";
49 print STDERR " perllib/classify directory.\n\n";
50 print STDERR " -xml Produces the information in an xml form, without\n";
51 print STDERR " 'pretty' comments but with much more detail.\n";
52}
53
54&main ();
55
56sub main {
57 my $collect = "";
58 my $xml = 0;
59
60 # Parse command line
61 if (!parsargv::parse(\@ARGV, q^collect/.*/^, \$collect, q^xml^, \$xml ))
62 {
63 &print_usage();
64 die "\n";
65 }
66
67 # Get classifier
68 my $classifier = shift (@ARGV);
69 if (!defined $classifier || $classifier eq "") {
70 print STDERR "You must provide a classifier name\n";
71 &print_usage();
72 die "\n";
73 }
74
75 # make sure the classifier is loaded from the correct location - a hack.
76 if ($collect ne "") {
77 $ENV{'GSDLCOLLECTDIR'} = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collect);
78 } else {
79 $ENV{'GSDLCOLLECTDIR'} = $ENV{'GSDLHOME'};
80 }
81
82 my $classinfo = &classify::load_classifiers ([[$classifier]]);
83 my $classobj = shift @$classinfo;
84
85 if ($xml) {
86 $classobj->print_xml_usage();
87 }
88 else {
89 print STDERR "
90$classifier info:
91
92Options may be passed to any classifier by including them in your collect.cfg
93configuration file.
94
95Classifiers may take two types of options:
96
97";
98 print STDERR "Specific options are defined within the classifier itself, and are available\n";
99 print STDERR "only to this particular classifier.\n\n";
100
101 print STDERR "General options are inherited from parent classes of the classifer.\n\n";
102
103 $classobj->print_txt_usage();
104 }
105}
106
107
108
109
Note: See TracBrowser for help on using the repository browser.