Sha256: 8eb59e2e7907d664df9f0fa177efb0a1a43b13a6730022c4ea10c4641f631fa4

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'tty-prompt'

module GitContext
  class Interaction
    def initialize(prompt = TTY::Prompt.new)
      @prompt = prompt
    end

    def prompt_work_dir(default_dir)
      @prompt.ask('Please enter working directory:', default: default_dir, required: true)
    end

    def prompt_profile(saved_profiles)
      @prompt.select('Please select from existing profiles:', saved_profiles, cycle: true)
    end

    def prompt_profile_name
      @prompt.ask('Please enter profile name:', required: true)
    end

    def prompt_user_info
      @prompt.collect do
        key(:name).ask('Please enter the name to be used in git config:')
        key(:email).ask('Please enter the email address to be used in git config:')
        key(:signing_key).ask('Please enter the signing key to be used in git config:')
      end
    end

    def prompt_delete_profile(saved_profiles)
      @prompt.select('Please select profile to be deleted:', saved_profiles, cycle: true)
    end

    def show(message)
      @prompt.say(message)
    end

    def info(message)
      @prompt.ok(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_context-0.3.0 lib/git_context/interaction.rb