lib/rouge/cli.rb in rouge-0.0.13 vs lib/rouge/cli.rb in rouge-0.0.14
- old
+ new
@@ -23,15 +23,17 @@
super(argv, *a)
end
desc 'highlight [FILE]', 'highlight some code'
- option :file, :aliases => '-f', :desc => 'the file to operate on'
+ option :input_file, :aliases => '-i', :desc => 'the file to operate on'
option :lexer, :aliases => '-l',
:desc => ('Which lexer to use. If not provided, rougify will try to ' +
'guess based on --mimetype, the filename, and the file ' +
'contents.')
+ option :formatter, :aliases => '-f', :default => 'html',
+ :desc => ('Which formatter to use.')
option :mimetype, :aliases => '-m',
:desc => ('a mimetype that Rouge will use to guess the correct lexer. ' +
'This is ignored if --lexer is specified.')
option :lexer_opts, :aliases => '-L', :type => :hash, :default => {},
:desc => ('a hash of options to pass to the lexer.')
@@ -50,11 +52,13 @@
else
lexer_class = Lexer.find(options[:lexer])
raise "unknown lexer: #{options[:lexer]}" unless lexer_class
end
+ formatter_class = Formatter.find(options[:formatter])
+
# only HTML is supported for now
- formatter = Formatters::HTML.new(normalize_hash_keys(options[:formatter_opts]))
+ formatter = formatter_class.new(normalize_hash_keys(options[:formatter_opts]))
lexer = lexer_class.new(normalize_hash_keys(options[:lexer_opts]))
puts Rouge.highlight(source, lexer, formatter)
end