#!/usr/bin/env ruby # For running when gem not installed $:.unshift File.dirname(File.dirname(__FILE__)) + "/lib" require "rubygems" require "optparse" require "guider/app" GUIDER_VERSION = '0.0.7' def format_footer(text) guider = "Guider" date = Time.new.strftime('%a %d %b %Y %H:%M:%S') text.gsub(/\{VERSION\}/, GUIDER_VERSION).gsub(/\{GUIDER\}/, guider).gsub(/\{DATE\}/, date) end options = { :output => Dir.pwd + "/out", :title => "Guides", :footer => format_footer("Generated on {DATE} by {GUIDER} {VERSION}."), :link_url => "http://localhost/extjs/", :tpl_dir => File.dirname(File.dirname(__FILE__)) + "/template", :warnings => false, } input_files = OptionParser.new do |opts| opts.banner = "Generates a guide.\n\n" + "Usage: guider \n\n" opts.on("-o", "--output=DIR", "Where to output the guides.", "Defaults to ./out") do |dir| options[:output] = File.expand_path(dir) end opts.on("--title=TEXT", "The title for the whole set of guides.", "Defaults to: Guides.") do |title| options[:title] = title end opts.on("--footer=TEXT", "The footer text.", "Defaults to: Generated on {DATE} by {GUIDER} {VERSION}.") do |footer| options[:footer] = format_footer(footer) end opts.on("--link-url=URL", "Base path for links created by {@link} tags.", "Defaults to http://localhost/extjs/") do |url| options[:link_url] = url end opts.on("--index=PATH", "The guides.json file to create index.html from.") do |path| options[:index] = path end opts.on("--warnings", "Enables warnings.") do options[:warnings] = true end opts.on("-h", "--help", "Show this help message") do puts opts exit end opts.on("--version", "Prints guider version number.") do puts "Guider #{GUIDER_VERSION}" exit end end.parse! if input_files.length == 1 options[:input] = File.expand_path(input_files[0]) else $stderr.puts "ERROR: Exactly one input directory must be specified." exit(1) end Guider::App.new(options).run