Sha256: 299d8f95f390e866ba7def7ece845ad55edf0e101fb9c7da3ef1eccd94bd76cb

Contents?: true

Size: 1.04 KB

Versions: 33

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

# Lifted from:
# https://github.com/rubysec/bundler-audit/blob/master/lib/bundler/audit/cli/thor_ext/shell/basic/say_error.rb
require 'English'
class Thor
  module Shell
    class Basic
      #
      # Prints an error message to `stderr`.
      #
      # @param [String] message
      #   The message to print to `stderr`.
      #
      # @param [Symbol, nil] color
      #   Optional ANSI color.
      #
      # @param [Boolean] force_new_line
      #   Controls whether a newline character will be appended to the output.
      #
      def say_error(message, color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
        return if quiet?

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

        stderr.print(buffer)
        stderr.flush
      end
    end

    module_eval <<-METHOD, __FILE__, __LINE__ + 1
      def say_error(*args,&block)
        shell.say_error(*args,&block)
      end
    METHOD
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
branch-name-4.0.3 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-4.0.2 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-4.0.1 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-4.0.0 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.10 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.9 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.8 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.7 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.6 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.5 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.4 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.3 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.2 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.1 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.10.0 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.9.0 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.8.0 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.7.0 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.6.0 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
branch-name-3.5.1 lib/branch/name/cli/thor_ext/shell/basic/say_error.rb