Class: Floe::CLI

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

Instance Method Summary collapse

Methods included from Logging

included, #logger, #logger=

Constructor Details

#initializeCLI

Returns a new instance of CLI.



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

def initialize
  require "optimist"
  require "logger"

  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
42
43
44
45
46
47
# File 'lib/floe/cli.rb', line 16

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

  credentials = create_credentials(opts)

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

  output_streams = create_loggers(workflows, opts[:segment_output])

  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|
    if workflows.size > 1
      logger.info("")
      logger.info("#{workflow.name}#{" (#{workflow.status})" unless workflow.context.success?}")
      logger.info("===")
    end

    logger.info(output_streams[workflow].string) if output_streams[workflow]
    logger.info(workflow.output)
  end

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