diff options
Diffstat (limited to 'lib/bundler/ui/shell.rb')
-rw-r--r-- | lib/bundler/ui/shell.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index 16e7cc70b5..32367a44f0 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -6,14 +6,17 @@ module Bundler module UI class Shell LEVELS = %w[silent error warn confirm info debug].freeze + OUTPUT_STREAMS = [:stdout, :stderr].freeze attr_writer :shell + attr_reader :output_stream def initialize(options = {}) Thor::Base.shell = options["no-color"] ? Thor::Shell::Basic : nil @shell = Thor::Base.shell.new @level = ENV["DEBUG"] ? "debug" : "info" @warning_history = [] + @output_stream = :stdout end def add_color(string, *color) @@ -101,6 +104,11 @@ module Bundler index <= LEVELS.index(@level) end + def output_stream=(symbol) + raise ArgumentError unless OUTPUT_STREAMS.include?(symbol) + @output_stream = symbol + end + def trace(e, newline = nil, force = false) return unless debug? || force msg = "#{e.class}: #{e.message}\n#{e.backtrace.join("\n ")}" @@ -119,6 +127,8 @@ module Bundler # valimism def tell_me(msg, color = nil, newline = nil) + return tell_err(msg, color, newline) if output_stream == :stderr + msg = word_wrap(msg) if newline.is_a?(Hash) && newline[:wrap] if newline.nil? @shell.say(msg, color) |