Sha256: c02d00797b3dffa766280d7d439f06ecba2daa6b6ec3a4004cf057f544b4c096

Contents?: true

Size: 856 Bytes

Versions: 8

Compression:

Stored size: 856 Bytes

Contents

# -*- coding: binary -*-
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

8 entries across 8 versions & 3 rubygems

Version Path
rex-2.0.5 lib/rex/ui/text/output/tee.rb
rex-2.0.4 lib/rex/ui/text/output/tee.rb
dstruct-0.0.1 lib/rex/ui/text/output/tee.rb
rex-2.0.3 lib/rex/ui/text/output/tee.rb
librex-0.0.999 lib/rex/ui/text/output/tee.rb
rex-2.0.2 lib/rex/ui/text/output/tee.rb
librex-0.0.71 lib/rex/ui/text/output/tee.rb
librex-0.0.70 lib/rex/ui/text/output/tee.rb