Class: GitContext::Interaction

Inherits:
Object
  • Object
show all
Defined in:
lib/git_context/interaction.rb

Instance Method Summary collapse

Constructor Details

#initialize(prompt = TTY::Prompt.new) ⇒ Interaction

Returns a new instance of Interaction.



7
8
9
# File 'lib/git_context/interaction.rb', line 7

def initialize(prompt = TTY::Prompt.new)
  @prompt = prompt
end

Instance Method Details

#info(message) ⇒ Object



39
40
41
# File 'lib/git_context/interaction.rb', line 39

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

#prompt_delete_profile(saved_profiles) ⇒ Object



31
32
33
# File 'lib/git_context/interaction.rb', line 31

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

#prompt_profile(saved_profiles) ⇒ Object



15
16
17
# File 'lib/git_context/interaction.rb', line 15

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

#prompt_profile_nameObject



19
20
21
# File 'lib/git_context/interaction.rb', line 19

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

#prompt_user_infoObject



23
24
25
26
27
28
29
# File 'lib/git_context/interaction.rb', line 23

def 
  @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

#prompt_work_dir(default_dir) ⇒ Object



11
12
13
# File 'lib/git_context/interaction.rb', line 11

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

#show(message) ⇒ Object



35
36
37
# File 'lib/git_context/interaction.rb', line 35

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