class SyntaxTree::CLI::Write
formatted output back to the file.
An action of the CLI that formats the input source and writes the
def run(item)
def run(item) filepath = item.filepath start = Time.now source = item.source formatted = item.handler.format( source, options.print_width, options: options.formatter_options ) changed = source != formatted File.write(filepath, formatted) if item.writable? && changed color = changed ? filepath : Color.gray(filepath) delta = ((Time.now - start) * 1000).round puts "#{color} #{delta}ms" rescue StandardError puts filepath raise end