Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/ui/text/output.rb
Views: 11655
# -*- coding: binary -*-12module Rex3module Ui4module Text56###7#8# This class implements text-based output but is not9# tied to an output medium.10#11###12class Output < Rex::Ui::Output1314require 'rex/text/color'1516include Rex::Text::Color1718def initialize19@config = {20:color => :auto, # true, false, :auto21}22super23end24attr_reader :config25attr_accessor :input2627def disable_color28@config[:color] = false29end3031def enable_color32@config[:color] = true33end3435def auto_color36@config[:color] = :auto37end3839def update_prompt(prompt = nil)40return if prompt.nil?41substitute_colors(prompt, true)42end4344def print_error(msg = '')45print_line("%bld%red[-]%clr #{msg}")46end4748alias_method :print_bad, :print_error4950def print_good(msg = '')51print_line("%bld%grn[+]%clr #{msg}")52end5354def print_status(msg = '')55print_line("%bld%blu[*]%clr #{msg}")56end5758def print_line(msg = '')59print(msg + "\n")60end6162def print_warning(msg = '')63print_line("%bld%yel[!]%clr #{msg}")64end6566def print(msg = '')67print_raw(substitute_colors(msg))68end6970def reset71end7273def puts(*args)74args.each do |argument|75line = argument.to_s76print_raw(line)7778unless line.ends_with? "\n"79# yes, this is output, but `IO#puts` uses `rb_default_rs`, which is80# [`$/`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/io.c#L12168-L12172),81# which is [`$INPUT_RECORD_SEPARATOR`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/lib/English.rb#L83)82print_raw($INPUT_RECORD_SEPARATOR)83end84end8586nil87end88end8990end91end92end93949596