lib/act/command.rb in act-0.0.4 vs lib/act/command.rb in act-0.0.5

- old
+ new

@@ -13,19 +13,20 @@ DOC def self.arguments [ - ['PATH', :optional], + CLAide::Argument.new('PATH', false), ] end def self.options [ ['--open', 'Open the file in $EDITOR instead of printing it'], ['--prettify', 'Prettify output'], - ['--line-numbers', 'Show output without line numbers'], + ['--always-color', 'Always color the output'], + ['--line-numbers', 'Show output with line numbers'], ['--lexer=NAME', 'Use the given lexer'], ].concat(super) end def self.completion_description @@ -39,10 +40,11 @@ @stdin = STDIN.read unless STDIN.tty? @open = argv.flag?('open') @prettify = argv.flag?('prettify', false) @number_lines = argv.flag?('line-numbers', false) @lexer = argv.option('lexer', false) + @always_color = argv.flag?('always-color') @file_string = argv.shift_argument super end def validate! @@ -128,15 +130,15 @@ end def cat_string(string, file = nil) if string path = file.path if file - @lexer ||= Helper.lexer(path) + @lexer ||= Helper.lexer(path, string) string = Helper.strip_indentation(string) string = Helper.prettify(string, @lexer) if @prettify - string = Helper.syntax_highlith(string, @lexer) if self.ansi_output? + string = Helper.syntax_highlight(string, @lexer) if ansi_output? || @always_color string = Helper.add_line_numbers(string, file.from_line, file.highlight_line) if @number_lines && file - UI.puts "\n#{string}" + UI.puts UI.tty? ? "\n#{string}" : string else UI.warn '[!] Nothing to show' end end end