class Ronin::CLI::Commands::Highlight
Syntax highlights a file(s).
## Usage
ronin highlight [options] [FILES ...]
## Options
-s, --syntax Specifies the syntax to highlight -L, --less Display the output in a pager -h, --help Print help information
## Arguments
[FILE ...] Option file(s) to process
Public Instance Methods
ansi?()
click to toggle source
Indicates that ANSI mode is always enabled.
@return [true]
# File lib/ronin/cli/commands/highlight.rb, line 72 def ansi? true end
process_file(file)
click to toggle source
Syntax highlights a file.
@param [String] file
Calls superclass method
# File lib/ronin/cli/commands/highlight.rb, line 81 def process_file(file) @syntax_lexer ||= syntax_lexer_for(filename: file) super(file) end
process_input(input)
click to toggle source
Syntax highlights an input stream.
@param [File, IO] input
The input file or `stdin`.
# File lib/ronin/cli/commands/highlight.rb, line 93 def process_input(input) if options[:less] pager do |less| syntax_highlight(input, output: less) end else syntax_highlight(input) end end
syntax_highlight(input, output: stdout)
click to toggle source
Syntax highlights the input stream and prints to the output stream.
@param [File, IO] input
The input file or `stdin`.
@param [IO] output
The `less` output stream or `stdout`.
# File lib/ronin/cli/commands/highlight.rb, line 112 def syntax_highlight(input, output: stdout) input.each_line do |line| output.print(@syntax_formatter.format(@syntax_lexer.lex(line))) end end