aboutsummaryrefslogtreecommitdiff
path: root/rakelib/support/ui.rb
blob: 3120721e0881a79ac0fb21cf559fba0b3f25a725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
# frozen_string_literal: true

require 'term/ansicolor'

# Terminal UI helpers for build milestones, debug logging, and operational errors.
module UI
  extend Term::ANSIColor

  def self.step(message)
    puts green(message)
  end

  def self.debug(message)
    puts "#{dark(' ->')} #{dark(message)}" if Rake.verbose
  end

  def self.fatal(message, hint: nil)
    output = red(message)
    output += "\n#{bold(cyan('Hint:'))} #{hint}" if hint
    abort output
  end
end