class Rouge::CLI
def self.class_from_arg(arg)
def self.class_from_arg(arg) case arg when 'version', '--version', '-v' Version when 'help' Help when 'highlight', 'hi' Highlight when 'style' Style when 'list' List end end
def self.doc
def self.doc return enum_for(:doc) unless block_given? yield %|usage: rougify [command] [args...]| yield %|| yield %|where <command> is one of:| yield %| highlight #{Highlight.desc}| yield %| help #{Help.desc}| yield %| style #{Style.desc}| yield %| list #{List.desc}| yield %| version #{Version.desc}| yield %|| yield %|See `rougify help <command>` for more info.| end
def self.error!(msg, status=1)
def self.error!(msg, status=1) raise Error.new(msg, status) end
def self.normalize_syntax(argv)
def self.normalize_syntax(argv) out = [] argv.each do |arg| case arg when /^(--\w+)=(.*)$/ out << $1 << $2 when /^(-\w)(.+)$/ out << $1 << $2 else out << arg end end out end
def self.parse(argv=ARGV)
def self.parse(argv=ARGV) argv = normalize_syntax(argv) mode = argv.shift klass = class_from_arg(mode) return klass.parse(argv) if klass case mode when '-h', '--help', 'help', '-help' Help.parse(argv) else argv.unshift(mode) if mode Highlight.parse(argv) end end
def error!(*a)
def error!(*a) self.class.error!(*a) end
def initialize(options={})
def initialize(options={}) end