#!/usr/bin/env ruby # vim: ft=ruby $: << 'lib' # debug only require "mdoc" require "optparse" options = {} optparse = OptionParser.new do |opts| opts.banner = "Usage: mdoc [options] filename.md" opts.separator "Options:" options[:type] = 'rtf' opts.on('-t TYPE', '--type TYPE', 'output file type') do |type| options[:type] = type end opts.on_tail('-h', '--help', 'Display this screen') do puts opts exit end end optparse.parse!(ARGV) file = ARGV[0] raise "Only markdown file (`*.md`) can be parsed" unless file =~ /\.md$/ klass = options[:type].to_s.capitalize eval("Mdoc::" + klass).new(file).convert