Class: Inquirex::TTY::Commands::Validate

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/inquirex/tty/commands/validate.rb

Overview

Validates a flow definition file: start step exists, all transition targets are known, and every step is reachable from the start step.

Instance Method Summary collapse

Instance Method Details

#call(flow_file:) ⇒ void

This method returns an undefined value.

Parameters:

  • flow_file (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/inquirex/tty/commands/validate.rb', line 15

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

  if errors.empty?
    print_success(definition)
  else
    print_errors(errors)
    exit 1
  end
rescue Inquirex::TTY::Error => e
  warn "Error: #{e.message}"
  exit 1
rescue Inquirex::Errors::Error => e
  warn "Definition error: #{e.message}"
  exit 1
end