Sha256: 46bec86cf50060c149d2510aee88b595a6dc926a6335a1b3ceb9025ddf8a5ba0

Contents?: true

Size: 578 Bytes

Versions: 5

Compression:

Stored size: 578 Bytes

Contents

require 'highline'

module GitHelper
  class HighlineCli
    def ask(prompt)
      cli.ask(prompt) do |conf|
        conf.readline = true
      end.to_s
    end

    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

    private def cli
      @cli ||= HighLine.new
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git_helper-1.2.0 lib/git_helper/highline_cli.rb
git_helper-1.1.1 lib/git_helper/highline_cli.rb
git_helper-1.1.0 lib/git_helper/highline_cli.rb
git_helper-1.0.1 lib/git_helper/highline_cli.rb
git_helper-1.0.0 lib/git_helper/highline_cli.rb