lib/rouge/cli.rb in rouge-3.5.1 vs lib/rouge/cli.rb in rouge-3.6.0
- old
+ new
@@ -36,20 +36,23 @@
class CLI
def self.doc
return enum_for(:doc) unless block_given?
- yield %|usage: rougify [command] [args...]|
+ yield %|usage: rougify {global options} [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 %| guess #{Guess.desc}|
yield %| version #{Version.desc}|
yield %||
+ yield %|global options:|
+ yield %[ --require|-r <fname> require <fname> after loading rouge]
+ yield %||
yield %|See `rougify help <command>` for more info.|
end
class Error < StandardError
attr_reader :message, :status
@@ -60,22 +63,26 @@
end
def self.parse(argv=ARGV)
argv = normalize_syntax(argv)
- mode = argv.shift
+ while (head = argv.shift)
+ case head
+ when '-h', '--help', 'help', '-help'
+ return Help.parse(argv)
+ when '--require', '-r'
+ require argv.shift
+ else
+ break
+ end
+ end
- klass = class_from_arg(mode)
+ klass = class_from_arg(head)
return klass.parse(argv) if klass
- case mode
- when '-h', '--help', 'help', '-help', nil
- Help.parse(argv)
- else
- argv.unshift(mode) if mode
- Highlight.parse(argv)
- end
+ argv.unshift(head) if head
+ Highlight.parse(argv)
end
def initialize(options={})
end
@@ -89,11 +96,11 @@
def self.class_from_arg(arg)
case arg
when 'version', '--version', '-v'
Version
- when 'help'
+ when 'help', nil
Help
when 'highlight', 'hi'
Highlight
when 'style'
Style
@@ -295,9 +302,10 @@
@formatter = case opts[:formatter]
when 'terminal256' then Formatters::Terminal256.new(theme)
when 'html' then Formatters::HTML.new
when 'html-pygments' then Formatters::HTMLPygments.new(Formatters::HTML.new, opts[:css_class])
when 'html-inline' then Formatters::HTMLInline.new(theme)
+ when 'html-line-table' then Formatters::HTMLLineTable.new(Formatters::HTML.new)
when 'html-table' then Formatters::HTMLTable.new(Formatters::HTML.new)
when 'null', 'raw', 'tokens' then Formatters::Null.new
when 'tex' then Formatters::Tex.new
else
error! "unknown formatter preset #{opts[:formatter]}"