Class: Floe::CLI

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/floe/cli.rb,
lib/floe/cli/logger.rb

Defined Under Namespace

Classes: Logger

Instance Method Summary collapse

Methods included from Logging

included, #logger, #logger=

Constructor Details

#initializeCLI

Returns a new instance of CLI.



11
12
13
14
# File 'lib/floe/cli.rb', line 11

def initialize
  Floe.logger = ::Logger.new($stdout)
  Floe.logger.level = 0 if ENV["DEBUG"]
end

Instance Method Details

#run(args = ARGV) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/floe/cli.rb', line 16

def run(args = ARGV)
  workflows_inputs, opts = parse_options!(args)

  show_execution_id = workflows_inputs.size > 1

  credentials = create_credentials(opts)

  workflows =
    workflows_inputs.map do |workflow, input|
      wf_logger = create_logger(show_execution_id)
      create_workflow(workflow, opts[:context], input, credentials, wf_logger)
    end

  logger.info("Checking #{workflows.count} workflows...")
  ready = Floe::Workflow.wait(workflows, &:run_nonblock)
  logger.info("Checking #{workflows.count} workflows...Complete - #{ready.count} ready")

  # Display status
  workflows.each do |workflow|
    logger.info("[#{workflow.context.execution_id}] #{workflow.name} (#{workflow.status}) - output: #{workflow.output}")
  end

  workflows.all? { |workflow| workflow.context.success? }
rescue Floe::Error => err
  abort(err.message)
end