Class: FlowEngine::CLI::Commands::Graph

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/flowengine/cli/commands/graph.rb

Instance Method Summary collapse

Instance Method Details

#call(flow_file:, **options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flowengine/cli/commands/graph.rb', line 13

def call(flow_file:, **options)
  definition = FlowLoader.load(flow_file)

  mermaid = FlowEngine::Graph::MermaidExporter.new(definition).export

  if options[:output]
    File.write(options[:output], mermaid)
    warn "Diagram written to #{options[:output]}"
  else
    puts mermaid
  end
rescue FlowEngine::CLI::Error => e
  warn "Error: #{e.message}"
  exit 1
end