Changeset 6921
- Timestamp:
- 2004-03-04T15:47:20+13:00 (20 years ago)
- Location:
- trunk/gsdl/bin/script
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/buildcol.pl
r6407 r6921 152 152 'args' => $arguments }; 153 153 154 155 sub print_xml_usage 154 sub gsprintf 156 155 { 157 local $language = shift(@_); 158 159 &PrintUsage::print_xml_header(); 160 161 print STDERR "<Info>\n"; 162 print STDERR " <Name>$options->{'name'}</Name>\n"; 163 print STDERR " <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n"; 164 print STDERR " <Arguments>\n"; 165 if (defined($options->{'args'})) { 166 &PrintUsage::print_options_xml($language, $options->{'args'}); 167 } 168 print STDERR " </Arguments>\n"; 169 print STDERR "</Info>\n"; 170 } 171 172 173 sub print_txt_usage 174 { 175 local $language = shift(@_); 176 177 local $programname = $options->{'name'}; 178 local $programargs = $options->{'args'}; 179 180 # Find the length of the longest option string 181 local $descoffset = 0; 182 if (defined($programargs)) { 183 $descoffset = &PrintUsage::find_longest_option_string($programargs); 184 } 185 186 # Produce the usage information using the data structure above 187 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 188 print STDERR " " . &lookup_string("{buildcol.params}") . "\n\n"; 189 190 # Display the program options, if there are some 191 if (defined($programargs)) { 192 # Calculate the column offset of the option descriptions 193 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 194 195 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 196 197 # Display the program options 198 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 199 } 200 } 201 202 203 sub lookup_string 204 { 205 return &gsprintf::lookup_string($language, shift(@_)); 156 return &gsprintf::gsprintf(@_); 206 157 } 207 158 … … 283 234 'gli', \$gli, 284 235 q^xml^, \$xml)) { 285 & print_txt_usage($language);236 &PrintUsage::print_txt_usage($language, $options, "{buildcol.params}"); 286 237 die "\n"; 287 238 } 288 239 289 240 if ($xml) { 290 & print_xml_usage($language);241 &PrintUsage::print_xml_usage($language, $options); 291 242 die "\n"; 292 243 } … … 296 247 if ($out !~ /^(STDERR|STDOUT)$/i) { 297 248 open (OUT, ">$out") || 298 die &lookup_string("{common.cannot_open_output_file}") . " $out\n";249 (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die); 299 250 $out = "buildcol::OUT"; 300 251 $close_out = 1; … … 304 255 # get and check the collection 305 256 if (($collection = &util::use_collection(@ARGV, $collectdir)) eq "") { 306 & print_txt_usage($language);257 &PrintUsage::print_txt_usage($language, $options, "{buildcol.params}"); 307 258 die "\n"; 308 259 } … … 314 265 # this could potentially create a situation where the faillog keeps being added 315 266 # to over multiple builds (if the import process is being skipped) 316 open (FAILLOG, ">>$faillog") 317 || die &lookup_string("{common.cannot_open_fail_log}") . " $faillog\n";267 open (FAILLOG, ">>$faillog") || 268 (&gsprintf(STDERR, "{common.cannot_open_fail_log}\n", $faillog) && die); 318 269 $faillog = 'buildcol::FAILLOG'; 319 270 $faillog->autoflush(1); … … 393 344 394 345 } else { 395 die &lookup_string("{common.cannot_find_cfg_file}") . " $configfilename\n";346 &gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die; 396 347 } 397 348 … … 429 380 # update the archive cache if needed 430 381 if ($cachedir) { 431 print $out &lookup_string("{buildcol.updating_archive_cache}") . "\n"382 &gsprintf($out, "{buildcol.updating_archive_cache}\n") 432 383 if ($verbosity >= 1); 433 384 … … 491 442 $builder->make_infodatabase(); 492 443 } else { 493 die &lookup_string("{buildcol.unknown_mode}") . " $mode\n";444 (&gsprintf(STDERR, "{buildcol.unknown_mode}\n", $mode) && die); 494 445 } 495 446 … … 498 449 499 450 if (($realbuilddir ne $builddir) && !$debug) { 500 print $out &lookup_string("{buildcol.copying_back_cached_build}") . "\n"451 &gsprintf($out, "{buildcol.copying_back_cached_build}\n") 501 452 if ($verbosity >= 1); 502 453 &util::rm_r ($builddir); … … 515 466 my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon-1.2.pl"); 516 467 if (!-e $image_script) { 517 print $out &lookup_string("{buildcol.no_image_script}") . ": $image_script.";518 print $out &lookup_string("{buildcol.no_default_images}") . "\n\n";468 &gsprintf($out, "{buildcol.no_image_script}", $image_script); 469 &gsprintf($out, "{buildcol.no_default_images}\n\n"); 519 470 return; 520 471 } … … 531 482 # to be changed when the config file format changes) 532 483 if (!open (CFGFILE, $configfilename)) { 533 print $out &lookup_string("{buildcol.cannot_open_cfg_file}") . ": $configfilename\n";534 print $out &lookup_string("{buildcol.unlinked_col_images}") . "\n";484 &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename); 485 &gsprintf($out, "{buildcol.unlinked_col_images}\n"); 535 486 return; 536 487 } … … 554 505 555 506 if (!open (CFGFILE, ">$configfilename")) { 556 print $out &lookup_string("{buildcol.cannot_open_cfg_file}") . ": $configfilename\n";557 print $out &lookup_string("{buildcol.unlinked_col_images}") . "\n";507 &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename); 508 &gsprintf($out, "{buildcol.unlinked_col_images}\n"); 558 509 return; 559 510 } -
trunk/gsdl/bin/script/classinfo.pl
r5882 r6921 61 61 'args' => $arguments }; 62 62 63 64 sub lookup_string 63 sub gsprintf 65 64 { 66 return &gsprintf::lookup_string($language, shift(@_)); 67 } 68 69 70 sub print_txt_usage 71 { 72 local $language = shift(@_); 73 74 local $programname = $options->{'name'}; 75 local $programargs = $options->{'args'}; 76 77 # Find the length of the longest option string 78 local $descoffset = 0; 79 if (defined($programargs)) { 80 $descoffset = &PrintUsage::find_longest_option_string($programargs); 81 } 82 83 # Produce the usage information using the data structure above 84 print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n"; 85 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 86 print STDERR " " . &lookup_string("{classinfo.params}") . "\n\n"; 87 88 # Display the program options, if there are some 89 if (defined($programargs)) { 90 # Calculate the column offset of the option descriptions 91 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 92 93 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 94 95 # Display the program options 96 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 97 } 65 return &gsprintf::gsprintf(@_); 98 66 } 99 67 … … 128 96 q^language/.*/^, \$language)) 129 97 { 130 & print_txt_usage($language);98 &PrintUsage::print_txt_usage($language, $options, "{classinfo.params}", 1); 131 99 die "\n"; 132 100 } … … 135 103 my $classifier = shift (@ARGV); 136 104 if (!defined $classifier || $classifier eq "") { 137 print STDERR &lookup_string("{classinfo.no_classifier_name}") . "\n\n";138 & print_txt_usage($language);105 &gsprintf(STDERR, "{classinfo.no_classifier_name}\n\n"); 106 &PrintUsage::print_txt_usage($language, $options, "{classinfo.params}", 1); 139 107 die "\n"; 140 108 } … … 154 122 } 155 123 else { 156 print STDERR "\n$classifier " . &lookup_string("{classinfo.info}") . ":\n\n";157 print STDERR &lookup_string("{classinfo.passing_options}") . "\n\n";158 print STDERR &lookup_string("{classinfo.option_types}") . ":\n\n";159 print STDERR &lookup_string("{classinfo.specific_options}") . "\n\n";160 print STDERR &lookup_string("{classinfo.general_options}") . "\n\n";124 &gsprintf(STDERR, "\n$classifier {classinfo.info}:\n\n"); 125 &gsprintf(STDERR, "{classinfo.passing_options}\n\n"); 126 &gsprintf(STDERR, "{classinfo.option_types}:\n\n"); 127 &gsprintf(STDERR, "{classinfo.specific_options}\n\n"); 128 &gsprintf(STDERR, "{classinfo.general_options}\n\n"); 161 129 162 130 $classobj->print_txt_usage($language); -
trunk/gsdl/bin/script/exportcol.pl
r6813 r6921 36 36 37 37 my $arguments = 38 [ { 'name' => "out", 38 [ { 'name' => "language", 39 'desc' => "{scripts.language}", 40 'type' => "string", 41 'reqd' => "no" }, 42 { 'name' => "out", 39 43 'desc' => "{exportcol.out}", 40 44 'type' => "string", … … 51 55 'args' => $arguments }; 52 56 53 sub print_xml_usage54 {55 local $language = shift(@_);56 57 &PrintUsage::print_xml_header();58 59 print STDERR "<Info>\n";60 print STDERR " <Name>$options->{'name'}</Name>\n";61 print STDERR " <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n";62 print STDERR " <Arguments>\n";63 if (defined($options->{'args'})) {64 &PrintUsage::print_options_xml($language, $options->{'args'});65 }66 print STDERR " </Arguments>\n";67 print STDERR "</Info>\n";68 }69 70 sub print_txt_usage71 {72 local $language = shift(@_);73 74 local $programname = $options->{'name'};75 local $programargs = $options->{'args'};76 77 # Find the length of the longest option string78 local $descoffset = 0;79 if (defined($programargs)) {80 $descoffset = &PrintUsage::find_longest_option_string($programargs);81 }82 83 # Produce the usage information using the data structure above84 print STDERR " " . &lookup_string("{common.usage}") . ": $programname";85 print STDERR " " . &lookup_string("{exportcol.params}") . "\n\n";86 87 # Display the program options, if there are some88 if (defined($programargs)) {89 # Calculate the column offset of the option descriptions90 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions91 92 print STDERR " " . &lookup_string("{common.options}") . ":\n";93 94 # Display the program options95 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);96 }97 }98 99 100 sub lookup_string101 {102 return &gsprintf::lookup_string($language, shift(@_));103 }104 105 57 sub gsprintf 106 58 { 107 59 return &gsprintf::gsprintf(@_); 108 60 } 61 109 62 110 63 #sub print_usage { … … 124 77 125 78 my $xml = 0; 126 127 if (!parsargv::parse(\@ARGV, 79 80 if (!parsargv::parse(\@ARGV, 81 'language/.*/', \$language, 128 82 'out/.*/STDERR', \$out, 129 83 'cdname/.*/', \$cdname, 130 84 q^xml^, \$xml)) { 131 132 & print_txt_usage();85 86 &PrintUsage::print_txt_usage($language, $options, "{exportcol.params}"); 133 87 die "\n"; 134 88 } 135 89 136 90 if ($xml) { 137 & print_xml_usage($language);138 die "\n"; 139 } 140 91 &PrintUsage::print_xml_usage($language, $options); 92 die "\n"; 93 } 94 141 95 my $dirname=""; 142 96 if ($cdname eq "") { … … 152 106 153 107 if (not @coll_list) { # empty list 154 & print_txt_usage();108 &PrintUsage::print_txt_usage($language, $options, "{exportcol.params}"); 155 109 exit(1); 156 110 } 157 111 158 112 my $close_out = 0; 159 113 if ($out !~ /^(STDERR|STDOUT)$/i) { 160 114 open (OUT, ">$out") || 161 die &lookup_string("{common.cannot_open_output_file}") . " $out\n";115 (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die); 162 116 $out = OUT; 163 117 $close_out = 1; … … 176 130 if ((!-d $colindexdir) || (!-d $coletcdir)) { 177 131 &gsprintf($out, "{exportcol.coll_dirs_not_found}\n", $c); 178 print $out " $colindexdir\n";179 print $out " $coletcdir\n";132 &gsprintf($out, " $colindexdir\n"); 133 &gsprintf($out, " $coletcdir\n"); 180 134 next; 181 135 } 182 136 # the collection seems ok, we add it to the valid coll list 183 137 push @valid_coll_list, $c; 184 185 138 } 186 139 187 140 if (not @valid_coll_list) { 188 141 # no valid colls left 189 &gsprintf($out, "{exportcol.fail}"); 190 &gsprintf($out, "{exportcol.no_valid_colls}\n"); 142 &gsprintf($out, "{exportcol.fail} {exportcol.no_valid_colls}\n"); 191 143 die "\n"; 192 144 } … … 196 148 &util::mk_all_dir ($topdir); 197 149 if (!-d $topdir) { 198 &gsprintf($out, "{exportcol.fail}"); 199 &gsprintf($out, "{exportcol.couldnt_create_dir}\n", $topdir); 150 &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_dir}\n", $topdir); 200 151 die "\n"; 201 152 } … … 215 166 my $installcfg = &util::filename_cat ($topdir, "install.cfg"); 216 167 if (!open (INSTALLCFG, ">$installcfg")) { 217 &gsprintf($out, "{exportcol.fail}"); 218 &gsprintf($out, "{exportcol.couldnt_create_file}\n", $installcfg ); 168 &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $installcfg); 219 169 die "\n"; 220 170 } … … 230 180 my $manifestcfg = &util::filename_cat ($topdir, "manifest.cfg"); 231 181 if (!open (MANIFESTCFG, ">$manifestcfg")) { 232 &gsprintf($out, "{exportcol.fail}"); 233 &gsprintf($out, "{exportcol.couldnt_create_file}\n", $manifestcfg ); 182 &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $manifestcfg); 234 183 die "\n"; 235 184 } … … 251 200 my $autoruninf = &util::filename_cat ($topdir, "Autorun.inf"); 252 201 if (!open (AUTORUNINF, ">$autoruninf")) { 253 &gsprintf($out, "{exportcol.fail}"); 254 &gsprintf($out, "{exportcol.couldnt_create_file}\n", $autoruninf ); 255 die "\n"; 256 } 257 202 &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $autoruninf); 203 die "\n"; 204 } 205 258 206 print AUTORUNINF "[autorun]\n"; 259 207 print AUTORUNINF "OPEN=Setup.exe\n"; 260 208 close AUTORUNINF; 261 209 262 210 # copy the necessary stuff from GSDLHOME 263 211 my $imagesdir = &util::filename_cat ($ENV{'GSDLHOME'}, "images"); … … 279 227 (!-d $net16dir) || (!-d $netscapedir) || (!-d $win32sdir) || (!-e $phindjar) || 280 228 (!-e $gsdlcollageappletjar)) { 281 &gsprintf($out, "{exportcol.fail}"); 282 &gsprintf($out, "{exportcol.non_exist_files}\n"); 283 print $out " $imagesdir\n"; 284 print $out " $macrosdir\n"; 285 print $out " $mappingsdir\n"; 286 print $out " $maincfg\n"; 287 print $out " $serverexe\n"; 288 print $out " $gssetupexe\n"; 289 print $out " $setupexe\n"; 290 print $out " $net32dir\n"; 291 print $out " $net16dir\n"; 292 print $out " $netscapedir\n"; 293 print $out " $win32sdir\n"; 294 print $out " $phindjar\n"; 295 print $out " $gsdlcollageappletjar\n"; 229 &gsprintf($out, "{exportcol.fail} {exportcol.non_exist_files}\n"); 230 &gsprintf($out, " $imagesdir\n"); 231 &gsprintf($out, " $macrosdir\n"); 232 &gsprintf($out, " $mappingsdir\n"); 233 &gsprintf($out, " $maincfg\n"); 234 &gsprintf($out, " $serverexe\n"); 235 &gsprintf($out, " $gssetupexe\n"); 236 &gsprintf($out, " $setupexe\n"); 237 &gsprintf($out, " $net32dir\n"); 238 &gsprintf($out, " $net16dir\n"); 239 &gsprintf($out, " $netscapedir\n"); 240 &gsprintf($out, " $win32sdir\n"); 241 &gsprintf($out, " $phindjar\n"); 242 &gsprintf($out, " $gsdlcollageappletjar\n"); 296 243 die "\n"; 297 244 } … … 335 282 &util::cp_r ($colimagesdir, $newcoldir) if (-e $colimagesdir); 336 283 337 # now we need to check the collect.cfg file to make sure it s public284 # now we need to check the collect.cfg file to make sure it's public 338 285 my $collectcfg = &util::filename_cat ($newcoldir, "etc", "collect.cfg"); 339 286 open INFILE, "<$collectcfg"; … … 356 303 } 357 304 &gsprintf($out, "{exportcol.success}"); 305 358 306 my $successcolls = ""; 359 307 my $first = 1; … … 365 313 } 366 314 $successcolls .= "$c"; 367 368 315 } 369 316 -
trunk/gsdl/bin/script/import.pl
r6775 r6921 66 66 my $arguments = 67 67 [ { 'name' => "archivedir", 68 'desc' => "{import.a chivedir}",68 'desc' => "{import.archivedir}", 69 69 'type' => "string", 70 70 'reqd' => "no", … … 159 159 'args' => $arguments }; 160 160 161 162 sub print_xml_usage 161 sub gsprintf 163 162 { 164 local $language = shift(@_); 165 166 &PrintUsage::print_xml_header(); 167 168 print STDERR "<Info>\n"; 169 print STDERR " <Name>$options->{'name'}</Name>\n"; 170 print STDERR " <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n"; 171 print STDERR " <Arguments>\n"; 172 if (defined($options->{'args'})) { 173 &PrintUsage::print_options_xml($language, $options->{'args'}); 174 } 175 print STDERR " </Arguments>\n"; 176 print STDERR "</Info>\n"; 177 } 178 179 180 sub print_txt_usage 181 { 182 local $language = shift(@_); 183 184 local $programname = $options->{'name'}; 185 local $programargs = $options->{'args'}; 186 187 # Find the length of the longest option string 188 local $descoffset = 0; 189 if (defined($programargs)) { 190 $descoffset = &PrintUsage::find_longest_option_string($programargs); 191 } 192 193 # Produce the usage information using the data structure above 194 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 195 print STDERR " " . &lookup_string("{import.params}") . "\n\n"; 196 197 # Display the program options, if there are some 198 if (defined($programargs)) { 199 # Calculate the column offset of the option descriptions 200 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 201 202 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 203 204 # Display the program options 205 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 206 } 207 } 208 209 210 sub lookup_string 211 { 212 return &gsprintf::lookup_string($language, shift(@_)); 163 return &gsprintf::gsprintf(@_); 213 164 } 214 165 … … 293 244 'gli', \$gli, 294 245 q^xml^, \$xml)) { 295 & print_txt_usage($language);246 &PrintUsage::print_txt_usage($language, $options, "{import.params}"); 296 247 die "\n"; 297 248 } 298 249 299 250 if ($xml) { 300 & print_xml_usage($language);251 &PrintUsage::print_xml_usage($language, $options); 301 252 die "\n"; 302 253 } … … 305 256 if ($out !~ /^(STDERR|STDOUT)$/i) { 306 257 open (OUT, ">$out") || 307 die &lookup_string("{common.cannot_open_output_file}") . " $out\n";258 (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die); 308 259 $out = 'import::OUT'; 309 260 $close_out = 1; … … 316 267 # get and check the collection name 317 268 if (($collection = &util::use_collection(@ARGV, $collectdir)) eq "") { 318 & print_txt_usage($language);269 &PrintUsage::print_txt_usage($language, $options, "{import.params}"); 319 270 die "\n"; 320 271 } … … 324 275 } 325 276 open (FAILLOG, ">$faillog") || 326 die &lookup_string("{import.cannot_open_fail_log}") . " $faillog\n";277 (&gsprintf(STDERR, "{import.cannot_open_fail_log}\n", $faillog) && die); 327 278 my $faillogname = $faillog; 328 279 $faillog = 'import::FAILLOG'; … … 332 283 $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/; 333 284 if (defined $sortmeta && $groupsize > 1) { 334 print $out &lookup_string("{import.cannot_sort}") . "\n\n";285 &gsprintf($out, "{import.cannot_sort}\n\n"); 335 286 $sortmeta = undef; 336 287 } … … 424 375 425 376 } else { 426 die &lookup_string("{common.cannot_find_cfg_file}") . " $configfilename\n";377 (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die); 427 378 } 428 379 … … 443 394 $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts); 444 395 if (scalar(@$pluginfo) == 0) { 445 print $out &lookup_string("{import.no_plugins_loaded}") . "\n";396 &gsprintf($out, "{import.no_plugins_loaded}\n"); 446 397 die "\n"; 447 398 } … … 449 400 # remove the old contents of the archives directory if needed 450 401 if ($removeold && -e $archivedir) { 451 print $out &lookup_string("{import.removing_archives}") . "\n";402 &gsprintf($out, "{import.removing_archives}\n"); 452 403 sleep(3); # just in case... 453 404 &util::rm_r ($archivedir); 454 405 } 455 406 456 407 # read the archive information file 457 408 if (!$debug) { … … 489 440 $close_stats = 1; 490 441 } else { 491 print $out &lookup_string("{import.cannot_open_stats_file}") . " $statsfile.";492 print $out &lookup_string("{import.stats_backup}") . "\n";442 &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile); 443 &gsprintf($out, "{import.stats_backup}\n"); 493 444 $statsfile = 'STDERR'; 494 445 } 495 446 } 496 447 497 print $out "\n";498 print $out "*********************************************\n";499 print $out &lookup_string("{import.complete}") . "\n";500 print $out "*********************************************\n";448 &gsprintf($out, "\n"); 449 &gsprintf($out, "*********************************************\n"); 450 &gsprintf($out, "{import.complete}\n"); 451 &gsprintf($out, "*********************************************\n"); 501 452 502 453 &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli); -
trunk/gsdl/bin/script/mkcol.pl
r6108 r6921 93 93 'args' => $arguments }; 94 94 95 96 sub print_xml_usage 95 sub gsprintf 97 96 { 98 local $language = shift(@_); 99 100 &PrintUsage::print_xml_header(); 101 102 print STDERR "<Info>\n"; 103 print STDERR " <Name>$options->{'name'}</Name>\n"; 104 print STDERR " <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n"; 105 print STDERR " <Arguments>\n"; 106 if (defined($options->{'args'})) { 107 &PrintUsage::print_options_xml($language, $options->{'args'}); 108 } 109 print STDERR " </Arguments>\n"; 110 print STDERR "</Info>\n"; 111 } 112 113 114 sub print_txt_usage 115 { 116 local $language = shift(@_); 117 118 local $programname = $options->{'name'}; 119 local $programargs = $options->{'args'}; 120 121 # Find the length of the longest option string 122 local $descoffset = 0; 123 if (defined($programargs)) { 124 $descoffset = &PrintUsage::find_longest_option_string($programargs); 125 } 126 127 # Produce the usage information using the data structure above 128 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 129 print STDERR " " . &lookup_string("{mkcol.params}") . "\n\n"; 130 131 # Display the program options, if there are some 132 if (defined($programargs)) { 133 # Calculate the column offset of the option descriptions 134 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 135 136 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 137 138 # Display the program options 139 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 140 } 141 } 142 143 144 sub lookup_string 145 { 146 return &gsprintf::lookup_string($language, shift(@_)); 97 return &gsprintf::gsprintf(@_); 147 98 } 148 99 … … 191 142 } 192 143 193 opendir(DIR, $modeldir) 194 || die &lookup_string("{common.cannot_read}") . " $modeldir";144 opendir(DIR, $modeldir) || 145 (&gsprintf(STDERR, "{common.cannot_read}\n", $modeldir) && die); 195 146 my @files = grep(!/^(\.\.?|CVS)$/, readdir(DIR)); 196 147 closedir(DIR); … … 207 158 $destfile =~ s/^modelcol/$collection/; 208 159 $destfile =~ s/^MODELCOL/$capcollection/; 209 print STDOUT " " . &lookup_string("{mkcol.doing_replacements}") . " $destfile\n"160 &gsprintf(STDOUT, "{mkcol.doing_replacements}\n", $destfile) 210 161 unless $quiet; 211 162 $destfile = &util::filename_cat ($coldir, $destfile); 212 163 213 164 open (INFILE, $thisfile) || 214 die &lookup_string("{common.cannot_read_file}") . " $thisfile";165 (&gsprintf(STDERR, "{common.cannot_read_file}\n", $thisfile) && die); 215 166 open (OUTFILE, ">$destfile") || 216 die &lookup_string("{common.cannot_create_file}") . " $destfile";167 (&gsprintf(STDERR, "{common.cannot_create_file}\n", $destfile) && die); 217 168 218 169 while (defined ($line = <INFILE>)) { … … 251 202 q^xml^, \$xml 252 203 )) { 253 & print_txt_usage($language);204 &PrintUsage::print_txt_usage($language, $options, "{mkcol.params}"); 254 205 die "\n"; 255 206 } … … 261 212 262 213 if ($xml) { 263 & print_xml_usage($language);214 &PrintUsage::print_xml_usage($language, $options); 264 215 die "\n"; 265 216 } … … 267 218 if ($optionfile =~ /\w/) { 268 219 open (OPTIONS, $optionfile) || 269 die &lookup_string("{common.cannot_open}") . " $optionfile\n";220 (&gsprintf(STDERR, "{common.cannot_open}\n", $optionfile) && die); 270 221 my $line = []; 271 222 my $options = []; … … 286 237 ($collection) = @ARGV; 287 238 if (!defined($collection)) { 288 print STDOUT &lookup_string("{mkcol.no_colname}") . "\n";289 & print_txt_usage($language);239 &gsprintf(STDOUT, "{mkcol.no_colname}\n"); 240 &PrintUsage::print_txt_usage($language, $options, "{mkcol.params}"); 290 241 die "\n"; 291 242 } 292 243 293 244 if (length($collection) > 8) { 294 print STDOUT &lookup_string("{mkcol.long_colname}") . "\n";245 &gsprintf(STDOUT, "{mkcol.long_colname}\n"); 295 246 die "\n"; 296 247 } 297 248 298 249 if ($collection eq "modelcol") { 299 print STDOUT &lookup_string("{mkcol.bad_name_modelcol}") . "\n";250 &gsprintf(STDOUT, "{mkcol.bad_name_modelcol}\n"); 300 251 die "\n"; 301 252 } 302 253 303 254 if ($collection eq "CVS") { 304 print STDOUT &lookup_string("{mkcol.bad_name_cvs}") . "\n";255 &gsprintf(STDOUT, "{mkcol.bad_name_cvs}\n"); 305 256 die "\n"; 306 257 } … … 308 259 # We don't want creator to be required anymore - John Thompson 28-11-2003 309 260 #if (!defined($creator) || $creator eq "") { 310 # print STDOUT &lookup_string("{mkcol.creator_undefined}") . "\n";261 # &gsprintf(STDOUT, "{mkcol.creator_undefined}\n"); 311 262 # die "\n"; 312 263 #} … … 336 287 if (defined $collectdir && $collectdir =~ /\w/) { 337 288 if (!-d $collectdir) { 338 print STDOUT &lookup_string("{mkcol.no_collectdir}") . ": $collectdir\n";289 &gsprintf(STDOUT, "{mkcol.no_collectdir}\n", $collectdir); 339 290 die "\n"; 340 291 } … … 345 296 346 297 # make sure the model collection exists 347 die &lookup_string("{mkcol.cannot_find_modelcol}") . " $mdir"unless (-d $mdir);298 (&gsprintf(STDERR, "{mkcol.cannot_find_modelcol}\n", $mdir) && die) unless (-d $mdir); 348 299 349 300 # make sure this collection does not already exist 350 301 if (-e $cdir) { 351 print STDOUT &lookup_string("{mkcol.col_already_exists}") . "\n";302 &gsprintf(STDOUT, "{mkcol.col_already_exists}\n"); 352 303 die "\n"; 353 304 } 354 305 355 306 # start creating the collection 356 print STDOUT "\n" . &lookup_string("{mkcol.creating_col}") . " $collection...\n"307 &gsprintf(STDOUT, "\n{mkcol.creating_col}...\n", $collection) 357 308 unless $quiet; 358 309 &traverse_dir ($mdir, $cdir); 359 print STDOUT "\n" . &lookup_string("{mkcol.success}") . "\n$cdir\n"310 &gsprintf(STDOUT, "\n{mkcol.success}\n", $cdir) 360 311 unless $quiet; 361 312 } -
trunk/gsdl/bin/script/pluginfo.pl
r5882 r6921 63 63 'args' => $arguments }; 64 64 65 66 sub lookup_string 65 sub gsprintf 67 66 { 68 return &gsprintf:: lookup_string($language, shift(@_));67 return &gsprintf::gsprintf(@_); 69 68 } 70 71 72 sub print_txt_usage73 {74 local $language = shift(@_);75 76 local $programname = $options->{'name'};77 local $programargs = $options->{'args'};78 79 # Find the length of the longest option string80 local $descoffset = 0;81 if (defined($programargs)) {82 $descoffset = &PrintUsage::find_longest_option_string($programargs);83 }84 85 # Produce the usage information using the data structure above86 print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n";87 print STDERR " " . &lookup_string("{common.usage}") . ": $programname";88 print STDERR " " . &lookup_string("{pluginfo.params}") . "\n\n";89 90 # Display the program options, if there are some91 if (defined($programargs)) {92 # Calculate the column offset of the option descriptions93 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions94 95 print STDERR " " . &lookup_string("{common.options}") . ":\n";96 97 # Display the program options98 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);99 }100 }101 102 69 103 70 … … 112 79 q^language/.*/^, \$language)) 113 80 { 114 & print_txt_usage($language);81 &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1); 115 82 die "\n"; 116 83 } … … 118 85 my $plugin = shift (@ARGV); 119 86 if (!defined $plugin || $plugin eq "") { 120 print STDERR &lookup_string("{pluginfo.no_plugin_name}") . "\n\n";121 & print_txt_usage($language);87 &gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n"); 88 &PrintUsage::print_txt_usage($language, $options, "{pluginfo.params}", 1); 122 89 die "\n"; 123 90 } … … 136 103 } 137 104 else { 138 print STDERR "\n$plugin " . &lookup_string("{pluginfo.info}") . ":\n\n";139 print STDERR &lookup_string("{pluginfo.passing_options}") . "\n\n";140 print STDERR &lookup_string("{pluginfo.option_types}") . ":\n\n";141 print STDERR &lookup_string("{pluginfo.specific_options}") . "\n\n";142 print STDERR &lookup_string("{pluginfo.general_options}") . "\n\n";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"); 143 110 144 111 $plugobj->print_txt_usage($language); … … 155 122 $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1) 156 123 if (!defined $pid) { 157 print STDERR "pluginfo.pl - can't fork: $!";124 &gsprintf(STDERR, "pluginfo.pl - can't fork: $!"); 158 125 } else { 159 126 if ($pid != 0) { # parent (ie forking) process. child gets 0
Note:
See TracChangeset
for help on using the changeset viewer.