From 0e7f26767d16ba7f4a9adfa303876ed0aa10deb8 Mon Sep 17 00:00:00 2001 From: Jarrett Lusso Date: Wed, 1 May 2019 14:17:56 -0400 Subject: [PATCH] Fixed error handling to properly exit and display options --- bin/chorizo | 4 +++- lib/chorizo.rb | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/chorizo b/bin/chorizo index 953c658..94f9497 100755 --- a/bin/chorizo +++ b/bin/chorizo @@ -24,4 +24,6 @@ if opts[:target] == 'heroku' && !opts[:app] exit 1 end -Chorizo.new.run(opts[:environment], target: opts[:target], app: opts[:app]) +Chorizo.new.run( + opts[:environment], opts, target: opts[:target], app: opts[:app] +) diff --git a/lib/chorizo.rb b/lib/chorizo.rb index fe7aeed..ee21a41 100644 --- a/lib/chorizo.rb +++ b/lib/chorizo.rb @@ -50,7 +50,7 @@ def build_output(env, host) output end - def run(env, target: nil, app: nil) + def run(env, opts, target: nil, app: nil) if @config if target && target != @config[env]['target'] STDERR.puts 'WARNING: target differs from configuration'.red @@ -66,7 +66,8 @@ def run(env, target: nil, app: nil) unless target && @host_names.include?(target) error = "please specify a valid target [#{@host_names.join(', ')}]" STDERR.puts(error.red) - return + puts opts + exit 1 end case target @@ -75,7 +76,8 @@ def run(env, target: nil, app: nil) when 'heroku' unless app STDERR.puts 'please specify an app for heroku'.red - return + puts opts + exit 1 end heroku(env, app)