Class: SyntaxTree::CLI::Write
Overview
An action of the CLI that formats the input source and writes the formatted output back to the file.
Instance Method Summary collapse
Methods inherited from Action
Instance Method Details
#run(handler, filepath, source) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/syntax_tree/cli.rb', line 133 def run(handler, filepath, source) print filepath start = Time.now formatted = handler.format(source) File.write(filepath, formatted) color = source == formatted ? Color.gray(filepath) : filepath delta = ((Time.now - start) * 1000).round puts "\r#{color} #{delta}ms" rescue StandardError puts "\r#{filepath}" raise end |