Class: ActiverecordCallbackLens::CLI::App
- Inherits:
-
Thor
- Object
- Thor
- ActiverecordCallbackLens::CLI::App
- 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
-
.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.
Instance Method Summary collapse
-
#analyze(model_name) ⇒ void
Runs the analysis pipeline for
model_nameand prints the result.
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.
28 29 30 |
# File 'lib/activerecord_callback_lens/cli/cli.rb', line 28 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.
42 43 44 45 46 47 |
# File 'lib/activerecord_callback_lens/cli/cli.rb', line 42 def analyze(model_name) model_class = resolve_model(model_name) graph = build_graph(model_class, expand: [:expand]) puts Renderer::MermaidRenderer.render(graph) if [:mermaid] puts Renderer::GraphvizRenderer.render(graph) if [:graphviz] end |