Class: Inquirex::TTY::Commands::Graph
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Inquirex::TTY::Commands::Graph
- Defined in:
- lib/inquirex/tty/commands/graph.rb
Overview
Exports a flow definition as a Mermaid flowchart (stdout or file).
Constant Summary collapse
- LONG_DESCRIPTION =
"Export a flow definition as a Mermaid diagram source, an image, or both.\n " \ "Image generation requires mermaid-cli (npm install -g @mermaid-js/mermaid-cli)\n " \ "which this gem will attempt to install for you if mmdc command is not available.\n\n" \ "Example:\n inquirex graph qualify_dsl.rb --format both --output ~/Desktop --open"
- SHORT_DESCRIPTION =
"Export a flow definition as a Mermaid diagram source, an image, or both."
Instance Method Summary collapse
Instance Method Details
#call(flow_file:, **options) ⇒ void
This method returns an undefined value.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/inquirex/tty/commands/graph.rb', line 41 def call(flow_file:, **) definition = FlowLoader.load(flow_file) source = Inquirex::Graph::MermaidExporter.new(definition).export format = [:format] || "source" output = [:output] case format when "source" write_source(source, OutputPath.resolve(flow_file, output, ".mmd")) when "image" write_image(source, OutputPath.resolve_with_default(flow_file, output, ".png"), [:open]) when "both" write_source(source, OutputPath.resolve(flow_file, output, ".mmd")) write_image(source, OutputPath.resolve_with_default(flow_file, output, ".png"), [:open]) end rescue Inquirex::TTY::Error => e warn "Error: #{e.}" exit 1 end |