Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Fixed error handling to properly exit and display options
Browse files Browse the repository at this point in the history
  • Loading branch information
jclusso committed May 1, 2019
1 parent 8471da8 commit 0e7f267
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bin/chorizo
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
8 changes: 5 additions & 3 deletions lib/chorizo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 0e7f267

Please sign in to comment.