diff --git a/lib/floe/cli.rb b/lib/floe/cli.rb index 50b4b6ef..4698cc7f 100644 --- a/lib/floe/cli.rb +++ b/lib/floe/cli.rb @@ -13,12 +13,7 @@ def initialize def run(args = ARGV) workflows_inputs, opts = parse_options!(args) - credentials = - if opts[:credentials_given] - opts[:credentials] == "-" ? $stdin.read : opts[:credentials] - elsif opts[:credentials_file_given] - File.read(opts[:credentials_file]) - end + credentials = create_credentials(opts) workflows = workflows_inputs.each_slice(2).map do |workflow, input| @@ -82,6 +77,16 @@ def parse_options!(args) return workflows_inputs, opts end + def create_credentials(opts) + if opts[:credentials_given] + opts[:credentials] == "-" ? $stdin.read : opts[:credentials] + elsif opts[:credentials_file_given] + File.read(opts[:credentials_file]) + else + {} + end + end + def create_workflow(workflow, context_payload, input, credentials) context = Floe::Workflow::Context.new(context_payload, :input => input, :credentials => credentials) Floe::Workflow.load(workflow, context)