class SyntaxTree::CLI::Expr

An action of the CLI that outputs a pattern-matching Ruby expression that would match the first expression of the input given.

Public Instance Methods

run(item) click to toggle source
# File lib/syntax_tree/cli.rb, line 298
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