Module: Ronin::Support::CLI::Printing

Included in:
Mixin
Defined in:
lib/ronin/support/cli/printing.rb

Overview

Printing methods.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debug=(value) ⇒ Object (writeonly)

Enables or disables debug mode.

Since:

  • 1.0.0



62
63
64
# File 'lib/ronin/support/cli/printing.rb', line 62

def debug=(value)
  @debug = value
end

Class Method Details

.debug=(debug_mode) ⇒ Boolean

Sets the debug mode.

Parameters:

  • debug_mode (Boolean)

    The new debug mode.

Returns:

  • (Boolean)

    The new debug mode.

Since:

  • 1.0.0



55
56
57
# File 'lib/ronin/support/cli/printing.rb', line 55

def self.debug=(debug_mode)
  @debug = debug_mode
end

.debug?Boolean

The current debug mode.

Returns:

  • (Boolean)

    The new debug mode.

Since:

  • 1.0.0



40
41
42
# File 'lib/ronin/support/cli/printing.rb', line 40

def self.debug?
  @debug
end

Instance Method Details

#debug?Boolean

Determines if debug mode has been enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



71
72
73
# File 'lib/ronin/support/cli/printing.rb', line 71

def debug?
  @debug || Printing.debug?
end
Note:

Will return false unless verbose printing is enabled.

Prints a debug message.

Examples:

print_debug "debug information here"
# [?] debug information here

Parameters:

  • message (String)

    The message to print.

Returns:

  • (Boolean)

    Specifies whether the messages were successfully printed.

Since:

  • 1.0.0



115
116
117
118
119
120
121
122
# File 'lib/ronin/support/cli/printing.rb', line 115

def print_debug(message)
  if debug?
    $stdout.puts "#{ANSI.bold(ANSI.yellow('[?]'))} #{message}#{ANSI.reset}"
    return true
  else
    return false
  end
end

Prints an error message.

Examples:

print_error "Could not connect!"
# [!] Could not connect!

Parameters:

  • message (String)

    The message to print.

Returns:

  • (Boolean)

    Specifies whether the messages were successfully printed.

Since:

  • 1.0.0



159
160
161
162
# File 'lib/ronin/support/cli/printing.rb', line 159

def print_error(message)
  $stdout.puts "#{ANSI.bold(ANSI.red('[!]'))} #{message}#{ANSI.reset}"
  return true
end

Prints an info message.

Examples:

print_info "Connecting ..."
# [*] Connecting ...

Parameters:

  • message (String)

    The message to print.

Returns:

  • (Boolean)

    Specifies whether the messages were successfully printed.

Since:

  • 1.0.0



90
91
92
93
# File 'lib/ronin/support/cli/printing.rb', line 90

def print_info(message)
  $stdout.puts "#{ANSI.bold(ANSI.white('[*]'))} #{message}#{ANSI.reset}"
  return true
end

Prints a negative message.

Examples:

print_negative "Password failed!"
# [-] Password failed!

Parameters:

  • message (String)

    The message to print.

Returns:

  • (Boolean)

    Specifies whether the messages were successfully printed.

Since:

  • 1.0.0



206
207
208
209
# File 'lib/ronin/support/cli/printing.rb', line 206

def print_negative(message)
  $stdout.puts "#{ANSI.bold(ANSI.red('[-]'))} #{message}#{ANSI.reset}"
  return true
end

Prints a positive message.

Examples:

print_positive "Password worked!"
# [+] Password worked!

Parameters:

  • message (String)

    The message to print.

Returns:

  • (Boolean)

    Specifies whether the messages were successfully printed.

Since:

  • 1.0.0



181
182
183
184
# File 'lib/ronin/support/cli/printing.rb', line 181

def print_positive(message)
  $stdout.puts "#{ANSI.bold(ANSI.green('[+]'))} #{message}#{ANSI.reset}"
  return true
end

Prints a warning message.

Examples:

print_warning "Rate limit exceeded, slowing down scanning."
# [~] Rate limit exceeded, slowing down scanning.

Parameters:

  • message (String)

    The message to print.

Returns:

  • (Boolean)

    Specifies whether the messages were successfully printed.

Since:

  • 1.0.0



139
140
141
142
# File 'lib/ronin/support/cli/printing.rb', line 139

def print_warning(message)
  $stdout.puts "#{ANSI.bold(ANSI.yellow('[~]'))} #{message}#{ANSI.reset}"
  return true
end