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 =

Multi-line help text shown by inquirex export --help.

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

One-line summary shown in the top-level command listing.

"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)


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

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
  $stderr.puts "Error: #{e.message}"
  exit 1
end