]> granicus.if.org Git - docbook-dsssl/commitdiff
Adding --output option to dbtoepub based on user request
authorKeith Fahlgren <abdelazer@users.sourceforge.net>
Sat, 4 Apr 2009 23:13:24 +0000 (23:13 +0000)
committerKeith Fahlgren <abdelazer@users.sourceforge.net>
Sat, 4 Apr 2009 23:13:24 +0000 (23:13 +0000)
xsl/epub/bin/dbtoepub

index a6a4316597361460aa9ab8dcffa4612778e579cf..d864024e3912de043cc13c651749fa623d81c810 100755 (executable)
@@ -30,6 +30,7 @@ debug = false
 css_file = nil
 otf_files = []
 customization_layer = nil
+output_file = nil
 
 # Set up the OptionParser
 opts = OptionParser.new
@@ -47,6 +48,7 @@ opts.on("-c", "--css [FILE]", "Use FILE for CSS on generated XHTML.") {|f| css_f
 opts.on("-d", "--debug", "Show debugging output.") {debug = true; verbose = true}
 opts.on("-f", "--font [OTF FILE]", "Embed OTF FILE in .epub.") {|f| otf_files << f}
 opts.on("-h", "--help", "Display usage info.") {puts opts.to_s; exit 0}
+opts.on("-o", "--output [OUTPUT FILE]", "Output ePub file as OUTPUT FILE.") {|f| output_file = f}
 opts.on("-s", "--stylesheet [XSL FILE]", "Use XSL FILE as a customization layer (imports epub/docbook.xsl).") {|f| customization_layer = f}
 opts.on("-v", "--verbose", "Make output verbose.") {verbose = true}
 
@@ -59,7 +61,12 @@ end
 db_files.each {|docbook_file|
   dir = File.expand_path(File.join(Dir.tmpdir, ".epubtmp#{Time.now.to_f.to_s}"))
   e = DocBook::Epub.new(docbook_file, dir, css_file, customization_layer, otf_files)
-  epub_file = File.basename(docbook_file, ".xml") + ".epub"
+
+  if output_file
+    epub_file = output_file
+  else  
+    epub_file = File.basename(docbook_file, ".xml") + ".epub"
+  end  
   puts "Rendering DocBook file #{docbook_file} to #{epub_file}" if verbose
   e.render_to_file(epub_file)
 }