lib/travis/cli/api_command.rb in travis-1.9.2.travis.1285.9 vs lib/travis/cli/api_command.rb in travis-1.9.2.travis.1288.9

- old
+ new

@@ -30,14 +30,20 @@ on('-X', '--enterprise [NAME]', 'use enterprise setup (optionally takes name for multiple setups)') do |c, name| c.enterprise_name = name || 'default' end - on('--adapter ADAPTER', 'Faraday adapter to use for HTTP requests') do |c, adapter| - adapter.gsub! '-', '_' - require "faraday/adapter/#{adapter}" - require 'typhoeus/adapters/faraday' if adapter == 'typhoeus' - c.session.faraday_adapter = adapter.to_sym + on('--adapter ADAPTER', 'Faraday adapter to use for HTTP requests. If omitted, use Typhoeus if it is installed, ' \ + 'and Net::HTTP otherwise. See https://lostisland.github.io/faraday/adapters/ for more info') do |c, adapter| + begin + adapter.gsub! '-', '_' + require "faraday/adapter/#{adapter}" + require 'typhoeus/adapters/faraday' if adapter == 'typhoeus' + c.session.faraday_adapter = adapter.to_sym + rescue LoadError => e + warn "\`--adapter #{adapter}\` is given, but it is not installed. Run \`gem install #{adapter}\` and try again" + exit 1 + end end def initialize(*) @session = Travis::Client.new(:agent_info => "command #{command_name}") super