Class: SshMenu::Actions

Inherits:
Object
  • Object
show all
Defined in:
lib/sshmenu/actions.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Actions

Returns a new instance of Actions.



6
7
8
9
10
# File 'lib/sshmenu/actions.rb', line 6

def initialize(config)
  @general = config.general
  @connections = config.connections
  @config_file = config.config_file
end

Class Method Details

.ask_edit_with_default_editorObject



30
31
32
33
34
35
36
# File 'lib/sshmenu/actions.rb', line 30

def self.ask_edit_with_default_editor
  editor = Config.default_editor
  config = Config.default_config_file
  print "Edit #{config} using default editor '#{editor}' [y/N]? "

  exec("#{editor} #{config}") if STDIN.getc[/[Yy]/]
end

Instance Method Details

#connect(index) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sshmenu/actions.rb', line 17

def connect(index)
  conn = @connections[index]

  cmd = [@general['ssh_exec'],
    @general['ssh_opts'],
    conn['ssh_opts'],
    conn['user_host']
  ].join(' ')
  puts "Command is #{cmd}" if $DEBUG
  puts "Connecting to #{conn['user_host']}"
  exec(cmd)
end

#editObject



12
13
14
15
# File 'lib/sshmenu/actions.rb', line 12

def edit
  puts "Edit config file #@config_file"
  exec("#{@general['editor']} #@config_file")
end