class Rex::Ui::Text::Output
This class implements text-based output but is not tied to an output medium.
Attributes
config[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/rex/ui/text/output.rb, line 24 def initialize @config = { :color => :auto, # true, false, :auto } super end
Public Instance Methods
auto_color()
click to toggle source
# File lib/rex/ui/text/output.rb, line 40 def auto_color @config[:color] = :auto end
disable_color()
click to toggle source
# File lib/rex/ui/text/output.rb, line 32 def disable_color @config[:color] = false end
enable_color()
click to toggle source
# File lib/rex/ui/text/output.rb, line 36 def enable_color @config[:color] = true end
print(msg = '')
click to toggle source
# File lib/rex/ui/text/output.rb, line 69 def print(msg = '') print_raw(substitute_colors(msg)) end
print_error(msg = '')
click to toggle source
# File lib/rex/ui/text/output.rb, line 49 def print_error(msg = '') print_line("%bld%red[-]%clr #{msg}") end
print_good(msg = '')
click to toggle source
# File lib/rex/ui/text/output.rb, line 53 def print_good(msg = '') print_line("%bld%grn[+]%clr #{msg}") end
print_line(msg = '')
click to toggle source
# File lib/rex/ui/text/output.rb, line 61 def print_line(msg = '') print(msg + "\n") end
print_status(msg = '')
click to toggle source
# File lib/rex/ui/text/output.rb, line 57 def print_status(msg = '') print_line("%bld%blu[*]%clr #{msg}") end
print_warning(msg = '')
click to toggle source
# File lib/rex/ui/text/output.rb, line 65 def print_warning(msg = '') print_line("%bld%yel[!]%clr #{msg}") end
puts(*args)
click to toggle source
# File lib/rex/ui/text/output.rb, line 76 def puts(*args) args.each do |argument| line = argument.to_s print_raw(line) unless line.ends_with? "\n" # yes, this is output, but `IO#puts` uses `rb_default_rs`, which is # [`$/`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/io.c#L12168-L12172), # which is [`$INPUT_RECORD_SEPARATOR`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/lib/English.rb#L83) print_raw($INPUT_RECORD_SEPARATOR) end end nil end
reset()
click to toggle source
# File lib/rex/ui/text/output.rb, line 73 def reset end
update_prompt(prompt = nil)
click to toggle source
# File lib/rex/ui/text/output.rb, line 44 def update_prompt(prompt = nil) return if prompt.nil? substitute_colors(prompt, true) end