Sha256: 6fbe4d0f079d3ec81f2bb35ff44db63e5b3b9ed6368b358aab0bd999ad22fed5

Contents?: true

Size: 777 Bytes

Versions: 18

Compression:

Stored size: 777 Bytes

Contents

require 'rex/ui'

module Rex
module Ui
module Text

###
#
# This class implements output against a file and stdout
#
###
class Output::Tee < Rex::Ui::Text::Output

	attr_accessor :fd

	def initialize(path)
		self.fd = ::File.open(path, "ab")
		super()
	end

	def supports_color?
		case config[:color]
		when true
			return true
		when false
			return false
		else # auto
			term = Rex::Compat.getenv('TERM')
			return (term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil)
		end
	end

	#
	# Prints the supplied message to file output.
	#
	def print_raw(msg = '')
		$stdout.print(msg)
		$stdout.flush

		return if not self.fd
		self.fd.write(msg)
		self.fd.flush
		msg
	end

	def close
		self.fd.close if self.fd
		self.fd = nil
	end
end

end
end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/ui/text/output/tee.rb
librex-0.0.63 lib/rex/ui/text/output/tee.rb
librex-0.0.54 lib/rex/ui/text/output/tee.rb
librex-0.0.53 lib/rex/ui/text/output/tee.rb
librex-0.0.52 lib/rex/ui/text/output/tee.rb
librex-0.0.51 lib/rex/ui/text/output/tee.rb
librex-0.0.50 lib/rex/ui/text/output/tee.rb
librex-0.0.49 lib/rex/ui/text/output/tee.rb
librex-0.0.48 lib/rex/ui/text/output/tee.rb
librex-0.0.47 lib/rex/ui/text/output/tee.rb
librex-0.0.46 lib/rex/ui/text/output/tee.rb
librex-0.0.44 lib/rex/ui/text/output/tee.rb
librex-0.0.43 lib/rex/ui/text/output/tee.rb
librex-0.0.42 lib/rex/ui/text/output/tee.rb
librex-0.0.41 lib/rex/ui/text/output/tee.rb
librex-0.0.40 lib/rex/ui/text/output/tee.rb
librex-0.0.39 lib/rex/ui/text/output/tee.rb
librex-0.0.38 lib/rex/ui/text/output/tee.rb