module Doing::PromptSTD

STDOUT and STDERR methods

Public Instance Methods

clear_screen(msg = nil) click to toggle source

Clear the terminal screen

# File lib/doing/prompt/std.rb, line 9
def clear_screen(msg = nil)
  puts "\e[H\e[2J" if $stdout.tty?
  puts msg if msg.good?
end
restore_std() click to toggle source

Restore silenced STDOUT and STDERR

# File lib/doing/prompt/std.rb, line 27
def restore_std
  $stdout = STDOUT
  $stderr = STDERR
end
silence_std(file = '/dev/null') click to toggle source

Redirect STDOUT and STDERR to /dev/null or file

@param file [String] a file path to redirect to

# File lib/doing/prompt/std.rb, line 19
def silence_std(file = '/dev/null')
  $stdout = File.new(file, 'w')
  $stderr = File.new(file, 'w')
end