class BooticCli::Commands::Themes::Prompt

Attributes

shell[R]

Public Class Methods

new(shell = Thor::Shell::Color.new) click to toggle source
# File lib/bootic_cli/commands/themes.rb, line 304
def initialize(shell = Thor::Shell::Color.new)
  @shell = shell
end

Public Instance Methods

highlight(str, color = :bold) click to toggle source
# File lib/bootic_cli/commands/themes.rb, line 340
def highlight(str, color = :bold)
  shell.set_color str, color
end
notice(str) click to toggle source
# File lib/bootic_cli/commands/themes.rb, line 331
def notice(str)
  parts = [" --->", str]
  puts highlight parts.join(' ')
end
pause(string, color = nil) click to toggle source
# File lib/bootic_cli/commands/themes.rb, line 322
def pause(string, color = nil)
  begin
    input = shell.ask(string, color)
  rescue Interrupt
    say "\nCtrl-C received. Bailing out!", :magenta
    abort
  end
end
say(str, color = nil) click to toggle source
# File lib/bootic_cli/commands/themes.rb, line 336
def say(str, color = nil)
  shell.say str, color
end
yes_or_no?(question, default_answer) click to toggle source
# File lib/bootic_cli/commands/themes.rb, line 308
def yes_or_no?(question, default_answer)
  default_char = default_answer ? 'y' : 'n'

  begin
    input = shell.ask("#{question} [#{default_char}]").strip
  rescue Interrupt
    say "\nCtrl-C received. Bailing out!", :magenta
    abort
  end

  return default_answer if input == '' || input.downcase == default_char
  !default_answer
end