Class: SshyGuy::Screens::MainScreen

Inherits:
SshyGuy::Screen show all
Defined in:
lib/sshyguy/screens/main_screen.rb

Instance Attribute Summary

Attributes inherited from SshyGuy::Screen

#options, #prompt

Instance Method Summary collapse

Methods inherited from SshyGuy::Screen

#initialize, show

Constructor Details

This class inherits a constructor from SshyGuy::Screen

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sshyguy/screens/main_screen.rb', line 6

def show
  SshyGuy.log('MainScreen initialized')
  ShortcutScreen.show(options) if options[:shortcut]
  SshyGuy.log('Building server menu')
  label = 'Select a server.'
  servers = SshyGuy::Server.all
  server = prompt.select(label) do |select|
    select.enum '.'
    servers.each do |item|
      select.choice(item.to_label, item)
    end
    select.choice('Exit folder', :close_folder) if current_folder?
  end
  SshyGuy.log("Selected #{server.inspect}")
  if server == :close_folder
    MainScreen.show(options)
  else
    SshyGuy.log("Spawning server #{server.inspect}")
    server.spawn
  end
end