X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=main.rb;h=bc175fbf51ae33205a37735d1390872a3ea630e1;hp=2d7f68b25c33c6bf45dbb0e909e17e3146f53e5b;hb=291671015d4e88cbb7e7f3995109a88ee993aac6;hpb=b0ed11b1a03aab548e3c274dfd89732e8e11892f diff --git a/main.rb b/main.rb index 2d7f68b..bc175fb 100644 --- a/main.rb +++ b/main.rb @@ -1,3 +1,4 @@ +require 'store' require 'walkdir' outputDir = 'output' @@ -5,11 +6,34 @@ outputDir = 'output' books = [] imageCount = 0 +def handleArg(arg) + if "--purge" == arg + puts 'Purging database...' + @store.dropSchema() + elsif arg.start_with?("--") + abort('ERROR: Unrecognized option "' + arg + '".') + end +end + +@store = Store.new() +@store.connect() + +for arg in ARGV + handleArg(arg) +end + +@store.init_db() + for arg in ARGV - w = WalkDir.new(arg) - books += (w.books) + if ! arg.start_with?("--") + puts 'Scanning directory "' + arg + '"...' + w = WalkDir.new(@store, arg) + books += (w.books) + end end +puts 'Creating output...' + if ! Dir.exist?(outputDir) Dir.mkdir(outputDir) end @@ -65,3 +89,4 @@ open(outputDir + '/index.html', 'w') do |fd| fd.puts "" end +@store.disconnect()