From: Keith Fahlgren Date: Sat, 4 Apr 2009 23:13:24 +0000 (+0000) Subject: Adding --output option to dbtoepub based on user request X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53b7f13fa8ec1544e56a346928b36b7f2cefa996;p=docbook-dsssl Adding --output option to dbtoepub based on user request --- diff --git a/xsl/epub/bin/dbtoepub b/xsl/epub/bin/dbtoepub index a6a431659..d864024e3 100755 --- a/xsl/epub/bin/dbtoepub +++ b/xsl/epub/bin/dbtoepub @@ -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) }