- Timestamp:
- 2006-03-08T11:40:01+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/mkcol.pl
r9060 r11309 39 39 } 40 40 41 use pars argv;41 use parse2; 42 42 use util; 43 43 use cfgread; 44 use gsprintf ;44 use gsprintf 'gsprintf'; 45 45 use printusage; 46 47 use strict; 48 no strict 'subs'; # allow barewords (eg STDERR) as function arguments 49 50 my $public_list = 51 [ { 'name' => "true", 52 'desc' => "{mkcol.public.true}"}, 53 { 'name' => "false", 54 'desc' => "{mkcol.public.false}"} 55 ]; 56 57 my $win31compat_list = 58 [ { 'name' => "true", 59 'desc' => "{mkcol.win31compat.true}"}, 60 { 'name' => "false", 61 'desc' => "{mkcol.win31compat.false}"} 62 ]; 46 63 47 64 my $arguments = … … 65 82 { 'name' => "public", 66 83 'desc' => "{mkcol.public}", 67 'type' => " string",84 'type' => "enum", 68 85 'deft' => "true", 86 'list' => $public_list, 69 87 'reqd' => "no" }, 70 88 { 'name' => "title", … … 90 108 { 'name' => "win31compat", 91 109 'desc' => "{mkcol.win31compat}", 92 'type' => " string",110 'type' => "enum", 93 111 'deft' => "true", 94 'reqd' => "no" } ]; 112 'list' => $win31compat_list, 113 'reqd' => "no" }, 114 { 'name' => "gli", 115 'desc' => "", 116 'type' => "flag", 117 'reqd' => "no", 118 'hiddengli' => "yes" }, 119 { 'name' => "xml", 120 'desc' => "{scripts.xml}", 121 'type' => "flag", 122 'reqd' => "no", 123 'hiddengli' => "yes" } 124 ]; 95 125 96 126 my $options = { 'name' => "mkcol.pl", … … 98 128 'args' => $arguments }; 99 129 100 sub gsprintf 101 { 102 return &gsprintf::gsprintf(@_); 103 } 130 # options 131 my ($creator, $optionfile, $maintainer, $collectdir, $public, 132 $title, $about, $plugin, $quiet, $language, $win31compat, $gli); 133 134 #other variables 135 my ($collection, $capcollection, $pluginstring, @plugin); 136 137 &main(); 104 138 105 139 … … 126 160 closedir(DIR); 127 161 128 foreach $file (@files)162 foreach my $file (@files) 129 163 { 130 164 my $thisfile = &util::filename_cat ($modeldir, $file); … … 146 180 (&gsprintf(STDERR, "{common.cannot_create_file}\n", $destfile) && die); 147 181 148 while (defined ( $line = <INFILE>)) {182 while (defined (my $line = <INFILE>)) { 149 183 $line =~ s/\*\*collection\*\*/$collection/g; 150 184 $line =~ s/\*\*COLLECTION\*\*/$capcollection/g; … … 165 199 } 166 200 167 # get and check options 168 sub parse_args { 169 my ($argref) = @_; 170 if (!&parsargv::parse($argref, 171 'language/.*/', \$language, 172 'optionfile/.*/', \$optionfile, 173 'collectdir/.*/', \$collectdir, 174 'creator/\w+\@[\w\.]+/', \$creator, 175 'maintainer/\w+\@[\w\.]+/', \$maintainer, 176 'public/true|false/true', \$public, 177 'title/.+/', \$title, 178 'about/.+/', \$about, 179 'plugin/.+', \@plugin, 180 'quiet', \$quiet, 181 'win31compat/true|false/true', \$win31compat, 182 'gli', \$gli, 183 q^xml^, \$xml 184 )) { 201 202 sub main { 203 204 my $xml = 0; 205 206 my $hashParsingResult = {}; 207 my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options"); 208 # If there is more than one argument left after parsing, it mean user input too many arguments. 209 if($intArgLeftinAfterParsing > 1) 210 { 185 211 &PrintUsage::print_txt_usage($options, "{mkcol.params}"); 186 212 die "\n"; 187 213 } 188 } 189 190 sub main { 191 192 &parse_args (\@ARGV); 214 215 foreach my $strVariable (keys %$hashParsingResult) 216 { 217 eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}"; 218 } 219 193 220 194 221 # If $language has been specified, load the appropriate resource bundle 195 222 # (Otherwise, the default resource bundle will be loaded automatically) 196 if ($language ) {223 if ($language && $language =~ /\S/) { 197 224 &gsprintf::load_language_specific_resource_bundle($language); 198 225 } … … 200 227 if ($xml) { 201 228 &PrintUsage::print_xml_usage($options); 202 die "\n"; 229 print "\n"; 230 return; 203 231 } 204 232 … … 216 244 } 217 245 close OPTIONS; 218 &parse_args ($options); 219 } 220 246 my $optionsParsingResult = {}; 247 my $optionsParseFailed = "false"; 248 if (!parse2::parse($options,$arguments,$optionsParsingResult)) { 249 &PrintUsage::print_txt_usage($options, "{mkcol.params}"); 250 die "\n"; 251 } 252 253 foreach my $strVariable (keys %$optionsParsingResult) 254 { 255 eval "\$$strVariable = \$optionsParsingResult->{\"\$strVariable\"}"; 256 } 257 } 258 221 259 # load default plugins if none were on command line 222 260 if (!scalar(@plugin)) { … … 248 286 } 249 287 250 # We don't want creator to be required anymore - John Thompson 28-11-2003251 #if (!defined($creator) || $creator eq "") {252 # &gsprintf(STDOUT, "{mkcol.creator_undefined}\n");253 # die "\n";254 #}255 256 #Of course thats means we don't want to default maintainer unless a creator is provided257 288 if (defined($creator) && (!defined($maintainer) || $maintainer eq "")) { 258 289 $maintainer = $creator; … … 271 302 # get the strings to include. 272 303 $pluginstring = ""; 273 foreach $plugin (@plugin) { 274 $pluginstring .= "plugin $plugin\n"; 275 } 276 277 $mdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", "modelcol"); 304 foreach my $plug (@plugin) { 305 $pluginstring .= "plugin $plug\n"; 306 } 307 308 my $mdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", "modelcol"); 309 my $cdir; 278 310 if (defined $collectdir && $collectdir =~ /\w/) { 279 311 if (!-d $collectdir) { … … 303 335 } 304 336 305 &main (); 337
Note:
See TracChangeset
for help on using the changeset viewer.