Changeset 5606 for trunk/gsdl/bin/script/pluginfo.pl
- Timestamp:
- 2003-10-09T15:53:46+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/pluginfo.pl
r4873 r5606 40 40 use util; 41 41 use parsargv; 42 use gsprintf; 43 use printusage; 42 44 43 sub print_usage { 44 print STDERR "\n"; 45 print STDERR "pluginfo.pl: Prints information about a plugin.\n\n"; 46 print STDERR " usage: $0 [options] plugin\n\n"; 47 print STDERR " options:\n"; 48 print STDERR " -collect collection-name Giving a collection name will make pluginfo.pl\n"; 49 print STDERR " look in collect/collection-name/perllib/plugins\n"; 50 print STDERR " first. If the plugin is not found there it will\n"; 51 print STDERR " look in the general perllib/plugins directory.\n\n"; 52 print STDERR " -xml Produces the information in an xml form, without\n"; 53 print STDERR " 'pretty' comments but with much more detail.\n\n"; 54 print STDERR " -language language-code Language to display plugin options in (eg. 'en_US'\n"; 55 print STDERR " specifies American English). Requires translations\n"; 56 print STDERR " of the option descriptions to exist in the\n"; 57 print STDERR " perllib/strings_language-code.rb file.\n"; 45 46 my $arguments = 47 [ { 'name' => "collect", 48 'desc' => "{pluginfo.collect}", 49 'type' => "string", 50 'reqd' => "no" }, 51 { 'name' => "xml", 52 'desc' => "{scripts.xml}", 53 'type' => "flag", 54 'reqd' => "no" }, 55 { 'name' => "language", 56 'desc' => "{scripts.language}", 57 'type' => "string", 58 'reqd' => "no" } ]; 59 60 my $options = { 'name' => "pluginfo.pl", 61 'desc' => "{pluginfo.desc}", 62 'args' => $arguments }; 63 64 65 sub lookup_string 66 { 67 return &gsprintf::lookup_string($language, shift(@_)); 58 68 } 59 69 60 70 61 &main (); 71 sub print_txt_usage 72 { 73 local $language = shift(@_); 74 75 local $programname = $options->{'name'}; 76 local $programargs = $options->{'args'}; 77 78 # Find the length of the longest option string 79 local $descoffset = 0; 80 if (defined($programargs)) { 81 $descoffset = &PrintUsage::find_longest_option_string($programargs); 82 } 83 84 # Produce the usage information using the data structure above 85 print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n"; 86 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 87 print STDERR " " . &lookup_string("{pluginfo.params}") . "\n\n"; 88 89 # Display the program options, if there are some 90 if (defined($programargs)) { 91 # Calculate the column offset of the option descriptions 92 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 93 94 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 95 96 # Display the program options 97 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 98 } 99 } 100 101 102 # sub print_usage { 103 # print STDERR "\n"; 104 # print STDERR "pluginfo.pl: Prints information about a plugin.\n\n"; 105 # print STDERR " usage: $0 [options] plugin\n\n"; 106 # print STDERR " options:\n"; 107 # print STDERR " -collect collection-name Giving a collection name will make pluginfo.pl\n"; 108 # print STDERR " look in collect/collection-name/perllib/plugins\n"; 109 # print STDERR " first. If the plugin is not found there it will\n"; 110 # print STDERR " look in the general perllib/plugins directory.\n\n"; 111 # print STDERR " -xml Produces the information in an xml form, without\n"; 112 # print STDERR " 'pretty' comments but with much more detail.\n\n"; 113 # print STDERR " -language language-code Language to display plugin options in (eg. 'en_US'\n"; 114 # print STDERR " specifies American English). Requires translations\n"; 115 # print STDERR " of the option descriptions to exist in the\n"; 116 # print STDERR " perllib/strings_language-code.rb file.\n"; 117 # } 62 118 63 119 sub main { … … 71 127 q^language/.*/^, \$language)) 72 128 { 73 &print_ usage();129 &print_txt_usage($language); 74 130 die "\n"; 75 131 } … … 77 133 my $plugin = shift (@ARGV); 78 134 if (!defined $plugin || $plugin eq "") { 79 print STDERR "You must provide a plugin name\n";80 &print_ usage();135 print STDERR &lookup_string("{pluginfo.no_plugin_name}") . "\n\n"; 136 &print_txt_usage($language); 81 137 die "\n"; 82 138 } … … 95 151 } 96 152 else { 97 print STDERR "\n$plugin info:\n\n"; 98 99 print STDERR "Options may be passed to any plugin by including them in your collect.cfg\n"; 100 print STDERR "configuration file.\n\n"; 101 102 print STDERR "Plugins may take two types of options:\n\n"; 103 104 print STDERR "Specific options are defined within the plugin itself, and are available\n"; 105 print STDERR "only to this particular plugin.\n\n"; 106 107 print STDERR "General options are inherited from parent classes of the plugin.\n\n"; 153 print STDERR "\n$plugin " . &lookup_string("{pluginfo.info}") . ":\n\n"; 154 print STDERR &lookup_string("{pluginfo.passing_options}") . "\n\n"; 155 print STDERR &lookup_string("{pluginfo.option_types}") . ":\n\n"; 156 print STDERR &lookup_string("{pluginfo.specific_options}") . "\n\n"; 157 print STDERR &lookup_string("{pluginfo.general_options}") . "\n\n"; 108 158 109 159 $plugobj->print_txt_usage($language); … … 117 167 } 118 168 169 170 &main ();
Note:
See TracChangeset
for help on using the changeset viewer.