class Honeybadger::CLI::Heroku

def install(api_key)

def install(api_key)
  say("Installing Honeybadger #{VERSION} for Heroku")
  app = options[:app] || detect_heroku_app(false)
  say("Adding config HONEYBADGER_API_KEY=#{api_key} to Heroku.", :magenta)
  unless write_heroku_env({'HONEYBADGER_API_KEY' => api_key}, app)
    say('Unable to update heroku config. You may need to specify an app name with --app APP', :red)
    exit(1)
  end
  if env = heroku_var('RAILS_ENV', app, heroku_var('RACK_ENV', app))
    say('Installing deploy notification addon', :magenta)
    invoke :install_deploy_notification, [], { app: app, api_key: api_key, environment: env }
  else
    say('Skipping deploy notification installation: we were unable to determine the environment name from your Heroku app.', :yellow)
    say("To install manually, try `honeybadger heroku install_deploy_notification#{app ? " -a #{app}" : ""} -k #{api_key} --environment ENVIRONMENT`", :yellow)
  end
  say("Installation complete. Happy 'badgering!", :green)
end