Class: Inquirex::TTY::Commands::Export

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

Overview

Exports a flow definition as JSON or YAML (stdout or file).

Examples:

inquirex export examples/08_tax_preparer.rb             # JSON to stdout
inquirex export examples/08_tax_preparer.rb -f yml      # YAML to stdout
inquirex export examples/08_tax_preparer.rb -o .        # write 08_tax_preparer.json to cwd
inquirex export examples/08_tax_preparer.rb -f yml -o . # write 08_tax_preparer.yml to cwd
inquirex export examples/08_tax_preparer.rb -o out.json # write to out.json

Constant Summary collapse

LONG_DESCRIPTION =
"Export a flow definition as JSON or YAML.\n\n" \
"Example:\n  inquirex export examples/08_tax_preparer.rb -f yml -o ."
SHORT_DESCRIPTION =
"Export a flow definition as JSON or YAML ."

Instance Method Summary collapse

Instance Method Details

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

This method returns an undefined value.

Parameters:

  • flow_file (String)
  • options (Hash)


41
42
43
44
45
46
47
48
49
# File 'lib/inquirex/tty/commands/export.rb', line 41

def call(flow_file:, **options)
  definition = FlowLoader.load(flow_file)
  format = normalize_format(options[:format])
  content = serialize(definition, format)
  write(content, flow_file, options[:output], extension_for(format))
rescue Inquirex::TTY::Error => e
  warn "Error: #{e.message}"
  exit 1
end