#!/usr/bin/env ruby $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) require "jdoc" require "yaml" require "optparse" opt = OptionParser.new banner = 'Usage: jdoc [options]' opt.banner = banner Version = Jdoc::VERSION options = { html: false, html_template_path: nil, markdown_template_path: nil } opt.on("--html") { |_| options[:html] = true } opt.on("--html-template-path ERB_FILE") { |v| options[:html_template_path] = v } opt.on("--markdown-template-path ERB_FILE") { |v| options[:markdown_template_path] = v } opt.parse!(ARGV) unless path = ARGV[0] puts banner exit end case File.extname(path) when ".yml", ".yaml" schema = YAML.load_file(path) else str = File.read(path) schema = JSON.parse(str) end puts Jdoc::Generator.call( schema, html: options[:html], html_template_path: options[:html_template_path], markdown_template_path: options[:markdown_template_path], )