Class: ActiverecordCallbackLens::CLI::App

Inherits:
Thor
  • Object
show all
Defined in:
lib/activerecord_callback_lens/cli/cli.rb

Overview

Thor application exposing the callback_lens command-line interface.

For v0.1 it provides a single command, analyze, which runs the full pipeline (collect -> parse -> build graph -> render) and prints a Mermaid diagram to stdout. An unknown model name is reported with a friendly message and a non-zero exit status rather than a Ruby backtrace.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Tells Thor to exit with a non-zero status when a command raises, so the exit 1 paths below propagate a failure code to the shell.

Returns:

  • (Boolean)


23
24
25
# File 'lib/activerecord_callback_lens/cli/cli.rb', line 23

def self.exit_on_failure?
  true
end

Instance Method Details

#analyze(model_name) ⇒ void

This method returns an undefined value.

Runs the analysis pipeline for model_name and prints the result.

Parameters:

  • model_name (String)

    the ActiveRecord model class name



33
34
35
36
37
# File 'lib/activerecord_callback_lens/cli/cli.rb', line 33

def analyze(model_name)
  model_class = resolve_model(model_name)
  graph = build_graph(model_class)
  puts Renderer::MermaidRenderer.render(graph) if options[:mermaid]
end