Module: Rigor::ModuleGraph::CLI

Defined in:
lib/rigor/module_graph/cli.rb

Overview

Entry point for the ‘rigor-module-graph` executable.

Subcommands:

collect [PATHS...]   Run `rigor check` and write edges JSONL
dot     [FILE]       Render edges JSONL as Graphviz DOT
mermaid [FILE]       Render edges JSONL as Mermaid
cycles  [FILE]       Detect cycles and print them

Every reader subcommand takes the path to an edges file, or reads stdin if no path is given. Each reader supports ‘–kind` and `–confidence` filters so a noisy graph can be pruned without touching the JSONL on disk.

Defined Under Namespace

Modules: EdgeFilters Classes: ClassDiagramCmd, Collect, CollectError, Cycles, Render, RigorRunner, StatsCmd, View

Constant Summary collapse

DEFAULT_EDGES_PATH =
".rigor/module_graph/edges.jsonl"
DEFAULT_NODES_PATH =
".rigor/module_graph/nodes.jsonl"
SOURCE_FAMILY =
"plugin.module-graph"
EDGE_RULE =
"edge"
NODE_RULE =
"node"
USAGE =
<<~USAGE
  Usage: rigor-module-graph [command] [options] [paths]

  Default (no command): same as `view` — analyse the current
  directory, write an HTML report, and open it in a browser.

  Commands:
    view          [PATHS...]   Analyse, write HTML, open in a browser
    collect       [PATHS...]   Run `rigor check` and write edges + nodes JSONL
    dot           [FILE]       Render edges JSONL as Graphviz DOT
    mermaid       [FILE]       Render edges JSONL as Mermaid flowchart
    class-diagram [FILE]       Render edges + nodes as Mermaid classDiagram (UML)
    cycles        [FILE]       Detect cycles in edges JSONL
    stats         [FILE]       Per-namespace fan-in / fan-out report

  Run `rigor-module-graph <command> --help` for command-specific options.
USAGE

Class Method Summary collapse

Class Method Details

.run(argv, stdout: $stdout, stderr: $stderr, stdin: $stdin) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rigor/module_graph/cli.rb', line 46

def run(argv, stdout: $stdout, stderr: $stderr, stdin: $stdin)
  argv = argv.dup
  command = argv.shift
  case command
  when nil
    View.new(stdout: stdout, stderr: stderr).run([])
  when "view"
    View.new(stdout: stdout, stderr: stderr).run(argv)
  when "collect"
    Collect.new(stdout: stdout, stderr: stderr).run(argv)
  when "dot"
    Render.new(:dot, stdout: stdout, stderr: stderr, stdin: stdin).run(argv)
  when "mermaid"
    Render.new(:mermaid, stdout: stdout, stderr: stderr, stdin: stdin).run(argv)
  when "cycles"
    Cycles.new(stdout: stdout, stderr: stderr, stdin: stdin).run(argv)
  when "stats"
    StatsCmd.new(stdout: stdout, stderr: stderr, stdin: stdin).run(argv)
  when "class-diagram"
    ClassDiagramCmd.new(stdout: stdout, stderr: stderr, stdin: stdin).run(argv)
  when "-h", "--help", "help"
    stdout.puts USAGE
    0
  when "version", "-v", "--version"
    stdout.puts "rigor-module-graph #{Rigor::ModuleGraph::VERSION}"
    0
  else
    stderr.puts "rigor-module-graph: unknown command #{command.inspect}"
    stderr.puts USAGE
    2
  end
end