Module: Henitai::CLI::OperatorCommand

Included in:
Henitai::CLI
Defined in:
lib/henitai/cli/operator_command.rb

Overview

Implements ‘henitai operator`: lists the built-in operators with their human-readable descriptions and examples. Mixed into Henitai::CLI.

Constant Summary collapse

OPERATOR_METADATA =
{
  "ArithmeticOperator" => ["Arithmetic operators", "a + b -> a - b"],
  "EqualityOperator" => ["Comparison operators", "a == b -> a != b"],
  "LogicalOperator" => ["Boolean operators", "a && b -> a || b"],
  "BooleanLiteral" => ["Boolean literals", "true -> false"],
  "ConditionalExpression" => ["Conditional branches", "if cond then ... end"],
  "StringLiteral" => ["String literals", '"foo" -> ""'],
  "ReturnValue" => ["Return expressions", "return x -> return nil"],
  "ArrayDeclaration" => ["Array literals", "[1, 2] -> []"],
  "HashLiteral" => ["Hash literals", "{ a: 1 } -> {}"],
  "RangeLiteral" => ["Range literals", "1..5 -> 1...5"],
  "SafeNavigation" => ["Safe navigation", "user&.name -> user.name"],
  "PatternMatch" => ["Pattern matching", "in { x: Integer } -> in { x: String }"],
  "BlockStatement" => ["Block statements", "{ do_work } -> {}"],
  "MethodExpression" => ["Method calls", "call_service -> nil"],
  "AssignmentExpression" => ["Assignment expressions", "x += 1 -> x -= 1"],
  "MethodChainUnwrap" => ["Method chain unwrap", "a.b.c -> a.b"],
  "RegexMutator" => ["Regex literals", "/foo+/ -> /foo*/"],
  "UnaryOperator" => ["Unary operators", "-x -> x"],
  "UpdateOperator" => ["Compound assignment", "x += 1 -> x -= 1"]
}.freeze