#!/usr/bin/env ruby $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib") require 'optparse' require 'mizuho/generator' $KCODE = 'UTF-8' options = {} parser = OptionParser.new do |opts| opts.banner = "Usage: mizuho [options] INPUT" opts.separator "" opts.separator "Options:" opts.on("-t", "--template FILE", String, "Specify a template file to use.") do |value| options[:template] = value end opts.on("-m", "--multi-page", "Generate one file per chapter.") do |value| options[:multi_page] = value end opts.on("--icons-dir DIR", "Specify the directory in which icons\n" << "#{' ' * 37}should be searched. Defaults to\n" << "#{' ' * 37}'images/icons'.") do |value| options[:icons_dir] = value end opts.on("-o", "--output FILE", String, "Specify the output filename.") do |value| options[:output] = value end end begin parser.parse! rescue OptionParser::ParseError => e puts e puts puts "Please see '--help' for valid options." exit 1 end begin if ARGV.empty? puts parser exit 1 else Mizuho::Generator.new(ARGV[0], options).start end rescue Mizuho::GenerationError STDERR.puts "*** ERROR" exit 2 end