Changeset 1104
- Timestamp:
- 06/12/06 17:34:57 (2 years ago)
- Files:
-
- Trunk/tools/cooker/cook.rb (modified) (3 diffs)
- Trunk/tools/cooker/ginsu.rb (modified) (3 diffs)
- Trunk/tools/cooker/splitter.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Trunk/tools/cooker/cook.rb
r1086 r1104 11 11 class Optparse 12 12 def self.parse(args) 13 version = "Version: #{$VERSION} (#{$BUILD.gsub('$', '').strip})" 14 13 15 options = OpenStruct.new 16 options.help = "" 14 17 options.dest = "" 15 18 options.hashid = false 16 19 17 20 opts = OptionParser.new do |opts| 18 opts.banner = "Cooker Build: " + $BUILD + ", Version: " + $VERSION + "\nUsage: cook.rb recipename [options]" 21 opts.banner = "Cook #{version}\n" 22 opts.banner += "Usage: cook.rb recipename [...] [options]" 19 23 opts.separator "" 20 24 opts.separator "Specific options:" 21 25 22 opts.on("-d", "--dest [DESTINATION]", "Destination directory") do |dest|26 opts.on("-d", "--dest DESTINATION", "Destination directory") do |dest| 23 27 if(!File.exist?(dest)) 24 STDERR.puts("E rror: destination directory: " + dest + "does not exist.")28 STDERR.puts("ERROR - Destination directory '#{dest}' does not exist.") 25 29 exit 26 30 end … … 32 36 end 33 37 34 # No argument, shows at tail. This will print an options summary.35 # Try it and see!38 options.help = opts 39 36 40 opts.on_tail("-h", "--help", "Show this message") do 37 puts opts 41 puts options.help 42 exit 64 43 end 44 45 opts.on_tail("--version", "Show version") do 46 puts version 38 47 exit 64 39 48 end … … 46 55 options = Optparse.parse(ARGV) 47 56 57 if(ARGV.empty?) 58 puts options.help 59 exit 60 end 61 48 62 ARGV.each do |file| 49 63 if(!File.exist?(file)) 50 STDERR.puts("ERROR , File: " + file + " Does not exist.")64 STDERR.puts("ERROR - File '#{file}' does not exist.") 51 65 exit 52 66 end Trunk/tools/cooker/ginsu.rb
r1086 r1104 11 11 class Optparse 12 12 def self.parse(args) 13 version = "Version: #{$VERSION} (#{$BUILD.gsub('$', '').strip})" 14 13 15 options = OpenStruct.new 16 options.help = "" 14 17 options.dest = "" 15 18 16 19 opts = OptionParser.new do |opts| 17 opts.banner = "Ginsu Build: " + $BUILD + ", Version: " + $VERSION + "\nUsage: ginsu.rb [tiddlywikiname]" 20 opts.banner = "Ginsu #{version}\n" 21 opts.banner += "Usage: ginsu.rb tiddlywikiname [...] [options]" 18 22 opts.separator "" 19 23 opts.separator "Specific options:" 20 24 21 # No argument, shows at tail. This will print an options summary. 22 # Try it and see! 25 opts.on("-d", "--dest DESTINATION", "Destination directory") do |dest| 26 if(!File.exist?(dest)) 27 STDERR.puts("ERROR - Destination directory '#{dest}' does not exist.") 28 exit 29 end 30 options.dest = dest 31 end 32 33 options.help = opts 34 23 35 opts.on_tail("-h", "--help", "Show this message") do 24 puts opts 36 puts options.help 37 exit 64 38 end 39 40 opts.on_tail("--version", "Show version") do 41 puts version 25 42 exit 64 26 43 end … … 33 50 options = Optparse.parse(ARGV) 34 51 52 if(ARGV.empty?) 53 puts options.help 54 exit 55 end 56 35 57 ARGV.each do |file| 36 58 if(!File.exist?(file)) 37 STDERR.puts("ERROR : File: " + file + " Does not exist.")59 STDERR.puts("ERROR - File '#{file}' does not exist.") 38 60 exit 39 61 end … … 41 63 42 64 ARGV.each do |file| 43 splitter = Splitter.new(file )65 splitter = Splitter.new(file, options.dest) 44 66 splitter.split 45 67 end Trunk/tools/cooker/splitter.rb
r1103 r1104 4 4 5 5 class Splitter 6 def initialize(filename )6 def initialize(filename, outdir=nil) 7 7 @filename = filename 8 8 dirset = false 9 9 dirnum = 0; 10 dirname = outdir.nil? || outdir.empty? ? @filename : File.join(outdir, File.basename(@filename)) 10 11 while !dirset do 11 targetdir = @filename + "." + dirnum.to_s 12 if !File.exists?(targetdir) 13 @dirname = targetdir 12 @dirname = dirname + "." + dirnum.to_s 13 if !File.exists?(@dirname) 14 14 Dir.mkdir(@dirname) 15 15 dirset = true … … 38 38 end 39 39 if(tiddlerCount == 0) 40 puts " #{@filename}does not contain any tiddlers"40 puts "'#{@filename}' does not contain any tiddlers" 41 41 else 42 puts "\n #{@filename} processed, #{tiddlerCount.to_s} tiddlers written to #{@dirname}/"42 puts "\n'#{@filename}' processed, #{tiddlerCount.to_s} tiddlers written to '#{@dirname}'" 43 43 end 44 44 end