Class: Rigor::CLI::TypeOfCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/rigor/cli/type_of_command.rb,
sig/rigor.rbs

Overview

Executes the rigor type-of command.

The command is a thin probe over Rigor::Scope#type_of: it locates the deepest expression at a (file, line, column) triple and prints the inferred type, RBS erasure, and (optionally) the recorded fail-soft fallbacks.

Encapsulating the command in its own class keeps Rigor::CLI focused on dispatching and lets us evolve the type-of UX (extra flags, watch mode, streaming output) without bloating the CLI shell. Output formatting is delegated to TypeOfRenderer.

Defined Under Namespace

Classes: Result

Constant Summary collapse

USAGE =

Returns:

  • (String)
"Usage: rigor type-of [options] FILE:LINE:COL"

Instance Method Summary collapse

Constructor Details

#initializeTypeOfCommand

Returns a new instance of TypeOfCommand.

Parameters:

  • argv: (Array[String])
  • out: (Object)
  • err: (Object)


32
# File 'sig/rigor.rbs', line 32

def initialize: (argv: Array[String], out: untyped, err: untyped) -> void

Instance Method Details

#runInteger

Returns CLI exit status.

Returns:

  • (Integer)

    CLI exit status.



33
34
35
36
37
38
39
40
41
42
# File 'lib/rigor/cli/type_of_command.rb', line 33

def run
  options = parse_options
  buffer = Options.resolve_buffer_binding(options, err: @err)
  return CLI::EXIT_USAGE if buffer == :usage_error

  target = parse_position_argument(@argv)
  return CLI::EXIT_USAGE if target.nil?

  execute(target: target, options: options, buffer: buffer)
end