Module: Strata::CLI::ColorHelper

Defined in:
lib/strata/cli/helpers/color_helper.rb

Constant Summary collapse

THEME =
{
  success: :green,
  error: %i[red bold],
  warning: :yellow,
  info: :cyan,
  title: %i[cyan bold],
  highlight: %i[cyan bold],
  dim: :bright_black,
  primary: :blue,
  secondary: :magenta,
  border: %i[cyan dim],
  selected: %i[green bold],
  disabled: :dim
}.freeze

Class Method Summary collapse

Class Method Details

.border(text = nil) ⇒ Object



64
65
66
# File 'lib/strata/cli/helpers/color_helper.rb', line 64

def border(text = nil)
  apply_theme(:border, text)
end

.bright_cyan(text = nil) ⇒ Object



76
77
78
# File 'lib/strata/cli/helpers/color_helper.rb', line 76

def bright_cyan(text = nil)
  text ? pastel.bright_cyan(text) : :bright_cyan
end

.bright_green(text = nil) ⇒ Object



80
81
82
# File 'lib/strata/cli/helpers/color_helper.rb', line 80

def bright_green(text = nil)
  text ? pastel.bright_green(text) : :bright_green
end

.bright_yellow(text = nil) ⇒ Object



84
85
86
# File 'lib/strata/cli/helpers/color_helper.rb', line 84

def bright_yellow(text = nil)
  text ? pastel.bright_yellow(text) : :bright_yellow
end

.dim(text = nil) ⇒ Object



52
53
54
# File 'lib/strata/cli/helpers/color_helper.rb', line 52

def dim(text = nil)
  apply_theme(:dim, text)
end

.disabled(text = nil) ⇒ Object



72
73
74
# File 'lib/strata/cli/helpers/color_helper.rb', line 72

def disabled(text = nil)
  apply_theme(:disabled, text)
end

.error(text = nil) ⇒ Object



32
33
34
# File 'lib/strata/cli/helpers/color_helper.rb', line 32

def error(text = nil)
  apply_theme(:error, text)
end

.highlight(text = nil) ⇒ Object



48
49
50
# File 'lib/strata/cli/helpers/color_helper.rb', line 48

def highlight(text = nil)
  apply_theme(:highlight, text)
end

.info(text = nil) ⇒ Object



40
41
42
# File 'lib/strata/cli/helpers/color_helper.rb', line 40

def info(text = nil)
  apply_theme(:info, text)
end

.pastelObject



24
25
26
# File 'lib/strata/cli/helpers/color_helper.rb', line 24

def pastel
  @pastel ||= Pastel.new(enabled: $stdout.tty?)
end

.primary(text = nil) ⇒ Object



56
57
58
# File 'lib/strata/cli/helpers/color_helper.rb', line 56

def primary(text = nil)
  apply_theme(:primary, text)
end

.secondary(text = nil) ⇒ Object



60
61
62
# File 'lib/strata/cli/helpers/color_helper.rb', line 60

def secondary(text = nil)
  apply_theme(:secondary, text)
end

.selected(text = nil) ⇒ Object



68
69
70
# File 'lib/strata/cli/helpers/color_helper.rb', line 68

def selected(text = nil)
  apply_theme(:selected, text)
end

.success(text = nil) ⇒ Object



28
29
30
# File 'lib/strata/cli/helpers/color_helper.rb', line 28

def success(text = nil)
  apply_theme(:success, text)
end

.title(text = nil) ⇒ Object



44
45
46
# File 'lib/strata/cli/helpers/color_helper.rb', line 44

def title(text = nil)
  apply_theme(:title, text)
end

.warning(text = nil) ⇒ Object



36
37
38
# File 'lib/strata/cli/helpers/color_helper.rb', line 36

def warning(text = nil)
  apply_theme(:warning, text)
end