Class: SshKeySwitcher::Options::Select

Inherits:
Object
  • Object
show all
Extended by:
Contains, Utils
Defined in:
lib/ssh_key_switcher/options/select.rb

Constant Summary

Constants included from Contains

Contains::SERVER_NAMES, Contains::SSH_DIR, Contains::STRING_DETECT_OPENSSH_KEY

Class Method Summary collapse

Class Method Details

.add(path_open_ssh_key) ⇒ Object



21
22
23
24
25
# File 'lib/ssh_key_switcher/options/select.rb', line 21

def add(path_open_ssh_key)
  SshKeySwitcher::Utils::SshAgent.remove_all
  SshKeySwitcher::Utils::SshAgent.add(path_open_ssh_key)
  prompt.ok('OpenSSH key added successfully!')
end

.display_selectObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ssh_key_switcher/options/select.rb', line 7

def display_select
  ssh_keys = Helper.find_open_ssh_keys
  if ssh_keys.empty?
    prompt.error('No OpenSSH keys found in ~/.ssh')
    nil
  else
    prompt.select('Select an OpenSSH key:', select_options) do |menu|
      menu.enum '.'
      select_choices(menu, ssh_keys)
    end

  end
end