Class: SyntaxTree::CLI::Check
Overview
An action of the CLI that ensures that the filepath is formatted as expected.
Defined Under Namespace
Classes: UnformattedError
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
Methods inherited from Action
Constructor Details
This class inherits a constructor from SyntaxTree::CLI::Action
Instance Method Details
#failure ⇒ Object
151 152 153 |
# File 'lib/syntax_tree/cli.rb', line 151 def failure warn("The listed files did not match the expected format.") end |
#run(item) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/syntax_tree/cli.rb', line 132 def run(item) source = item.source formatted = item.handler.format( source, .print_width, options: . ) raise UnformattedError if source != formatted rescue StandardError warn("[#{Color.yellow("warn")}] #{item.filepath}") raise end |
#success ⇒ Object
147 148 149 |
# File 'lib/syntax_tree/cli.rb', line 147 def success puts("All files matched expected format.") end |