lib/rouge/cli.rb in rouge-2.0.7 vs lib/rouge/cli.rb in rouge-2.1.0

- old
+ new

@@ -167,32 +167,41 @@ yield %[] yield %[--formatter|-f <opts> specify the output formatter to use.] yield %[ If not provided, rougify will default to] yield %[ terminal256.] yield %[] + yield %[--theme|-t <theme> specify the theme to use for highlighting] + yield %[ the file. (only applies to some formatters)] + yield %[] yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing] yield %[] yield %[--lexer-opts|-L <opts> specify lexer options in CGI format] yield %[ (opt1=val1&opt2=val2)] yield %[] yield %[--formatter-opts|-F <opts> specify formatter options in CGI format] yield %[ (opt1=val1&opt2=val2)] + yield %[] + yield %[--require|-r <filename> require a filename or library before] + yield %[ highlighting] end def self.parse(argv) opts = { :formatter => 'terminal256', :theme => 'thankful_eyes', :css_class => 'codehilite', :input_file => '-', :lexer_opts => {}, :formatter_opts => {}, + :requires => [], } until argv.empty? arg = argv.shift case arg + when '-r', '--require' + opts[:requires] << argv.shift when '--input-file', '-i' opts[:input_file] = argv.shift when '--mimetype', '-m' opts[:mimetype] = argv.shift when '--lexer', '-l' @@ -236,10 +245,16 @@ end attr_reader :input_file, :lexer_name, :mimetype, :formatter def initialize(opts={}) + Rouge::Lexer.enable_debug! + + opts[:requires].each do |r| + require r + end + @input_file = opts[:input_file] if opts[:lexer] @lexer_class = Lexer.find(opts[:lexer]) \ or error! "unknown lexer #{opts[:lexer].inspect}" @@ -347,9 +362,14 @@ desc = "#{lexer.desc}" if lexer.aliases.any? desc << " [aliases: #{lexer.aliases.join(',')}]" end puts "%s: %s" % [lexer.tag, desc] + + lexer.option_docs.keys.sort.each do |option| + puts " ?#{option}= #{lexer.option_docs[option]}" + end + puts end end end