Class: SyntaxTree::CLI::Expr
Overview
An action of the CLI that outputs a pattern-matching Ruby expression that would match the first expression of the input given.
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
Methods inherited from Action
#failure, #initialize, #success
Constructor Details
This class inherits a constructor from SyntaxTree::CLI::Action
Instance Method Details
#run(item) ⇒ Object
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/syntax_tree/cli.rb', line 194 def run(item) program = item.handler.parse(item.source) if (expressions = program.statements.body) && expressions.size == 1 puts expressions.first.construct_keys else warn("The input to `stree expr` must be a single expression.") exit(1) end end |