Class: Thor::Shell::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/audit/cli/thor_ext/shell/basic/say_error.rb

Instance Method Summary collapse

Instance Method Details

#say_error(message, color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)) ⇒ Object

Prints an error message to stderr.

Parameters:

  • message (String)

    The message to print to stderr.

  • color (Symbol, nil) (defaults to: nil)

    Optional ANSI color.

  • force_new_line (Boolean) (defaults to: (message.to_s !~ /( |\t)\Z/))

    Controls whether a newline character will be appended to the output.



16
17
18
19
20
21
22
23
24
# File 'lib/bundler/audit/cli/thor_ext/shell/basic/say_error.rb', line 16

def say_error(message,color=nil,force_new_line=(message.to_s !~ /( |\t)\Z/))
  return if quiet?

  buffer = prepare_message(message,*color)
  buffer << $/ if force_new_line && !message.to_s.end_with?($/)

  stderr.print(buffer)
  stderr.flush
end