Class: GitHelper::HighlineCli

Inherits:
Object
  • Object
show all
Defined in:
lib/git_helper/highline_cli.rb

Instance Method Summary collapse

Instance Method Details

#ask(prompt) ⇒ Object



5
6
7
8
9
# File 'lib/git_helper/highline_cli.rb', line 5

def ask(prompt)
  cli.ask(prompt) do |conf|
    conf.readline = true
  end.to_s
end

#ask_options(prompt, choices) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/git_helper/highline_cli.rb', line 11

def ask_options(prompt, choices)
  choices_as_string_options = ''
  choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
  compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"

  cli.ask(compiled_prompt) do |conf|
    conf.readline = true
  end.to_i - 1
end