Class: SyntaxTree::CLI::Check

Inherits:
Action
  • Object
show all
Defined in:
lib/syntax_tree/cli.rb

Overview

An action of the CLI that ensures that the filepath is formatted as expected.

Defined Under Namespace

Classes: UnformattedError

Instance Method Summary collapse

Instance Method Details

#failureObject



67
68
69
# File 'lib/syntax_tree/cli.rb', line 67

def failure
  warn("The listed files did not match the expected format.")
end

#run(filepath, source) ⇒ Object



56
57
58
59
60
61
# File 'lib/syntax_tree/cli.rb', line 56

def run(filepath, source)
  raise UnformattedError if source != SyntaxTree.format(source)
rescue StandardError
  warn("[#{Color.yellow("warn")}] #{filepath}")
  raise
end

#successObject



63
64
65
# File 'lib/syntax_tree/cli.rb', line 63

def success
  puts("All files matched expected format.")
end