Class: Gitflash::Prompt

Inherits:
TTY::Prompt
  • Object
show all
Defined in:
lib/gitflash/prompt.rb

Overview

A wrapper class for TTY::Prompt gem

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Prompt

Returns a new instance of Prompt.



14
15
16
# File 'lib/gitflash/prompt.rb', line 14

def initialize(options)
  super(**default_create_options(options))
end

Class Method Details

.create(options: {}) ⇒ Object



9
10
11
# File 'lib/gitflash/prompt.rb', line 9

def create(options: {})
  new(options)
end

Instance Method Details

#multi_select(message, collection, options = {}) ⇒ Object



22
23
24
# File 'lib/gitflash/prompt.rb', line 22

def multi_select(message, collection, options = {})
  super(message, collection, default_select_options(options))
end

#proceed_with_warning(message, &block) ⇒ Object

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
# File 'lib/gitflash/prompt.rb', line 26

def proceed_with_warning(message, &block)
  raise ArgumentError, 'A block is required for this method' unless block_given?

  warn(message)
  answer = yes?('Do you want to proceed?')
  answer ? block.call : 'Exited'
end

#select(message, collection, options = {}) ⇒ Object



18
19
20
# File 'lib/gitflash/prompt.rb', line 18

def select(message, collection, options = {})
  super(message, collection, default_select_options(options))
end