Class: VagrantPlugins::Mosh::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-mosh/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



4
5
6
# File 'lib/vagrant-mosh/command.rb', line 4

def self.synopsis
  'connects to machine via Mosh'
end

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-mosh/command.rb', line 8

def execute
  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant mosh [vm-name]'
    o.separator ''
  end
  argv = parse_options(opts)
  return unless argv

  with_target_vms(argv, single_target: true) do |vm|
    ssh_info = vm.ssh_info
    switch_to_remote_ip(ssh_info, vm) if localhost?(ssh_info[:host])
    mosh_command = ['mosh', *mosh_arguments(ssh_info)].join(' ')
    Vagrant::Util::SafeExec.exec(mosh_command)
  end
end