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.

It provides a single command, analyze, which runs the full pipeline (collect -> parse -> build graph -> render) and prints the result to stdout. Output format is selectable per invocation: a Mermaid diagram (--mermaid, on by default) and/or a Graphviz DOT graph (--graphviz); the two flags are independent and may be combined. 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)


29
30
31
# File 'lib/activerecord_callback_lens/cli/cli.rb', line 29

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.

When –html FILE is given, a self-contained HTML report is written to FILE (in addition to any stdout output selected by the other flags) and a confirmation line is printed.

Parameters:

  • model_name (String)

    the ActiveRecord model class name



48
49
50
51
52
# File 'lib/activerecord_callback_lens/cli/cli.rb', line 48

def analyze(model_name)
  model_class = resolve_model(model_name)
  definitions, graph = build_pipeline(model_class, expand: options[:expand])
  render_outputs(graph, definitions)
end