Sha256: 86c5146f1f2975ad1a2527de216ba2408c91782e71c0a7a547a48114d932a77f
Contents?: true
Size: 854 Bytes
Versions: 1
Compression:
Stored size: 854 Bytes
Contents
# frozen_string_literal: true module GitHelper class HighlineCli def ask(prompt) highline_client.ask(prompt) do |conf| conf.readline = true end.to_s end def ask_yes_no(prompt) answer = highline_client.ask(prompt) do |conf| conf.readline = true end.to_s answer.empty? ? true : !!(answer =~ /^y/i) end def ask_options(prompt, choices) choices_as_string_options = ''.dup choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" } compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}" index = highline_client.ask(compiled_prompt) do |conf| conf.readline = true end.to_i - 1 choices[index] end private def highline_client @highline_client ||= HighLine.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_helper-3.3.2 | lib/git_helper/highline_cli.rb |