Class: BooticCli::Commands::Themes::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/bootic_cli/commands/themes.rb

Instance Method Summary collapse

Constructor Details

#initialize(shell = Thor::Shell::Color.new) ⇒ Prompt



278
279
280
# File 'lib/bootic_cli/commands/themes.rb', line 278

def initialize(shell = Thor::Shell::Color.new)
  @shell = shell
end

Instance Method Details

#highlight(str, color = :bold) ⇒ Object



314
315
316
# File 'lib/bootic_cli/commands/themes.rb', line 314

def highlight(str, color = :bold)
  shell.set_color str, color
end

#notice(str) ⇒ Object



305
306
307
308
# File 'lib/bootic_cli/commands/themes.rb', line 305

def notice(str)
  parts = [" --->", str]
  puts highlight parts.join(' ')
end

#pause(string, color = nil) ⇒ Object



296
297
298
299
300
301
302
303
# File 'lib/bootic_cli/commands/themes.rb', line 296

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) ⇒ Object



310
311
312
# File 'lib/bootic_cli/commands/themes.rb', line 310

def say(str, color = nil)
  shell.say str, color
end

#yes_or_no?(question, default_answer) ⇒ Boolean



282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/bootic_cli/commands/themes.rb', line 282

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