commands/rdp: basic skeleton
This commit is contained in:
parent
2929f7a853
commit
de7b4bbdc1
|
@ -0,0 +1,28 @@
|
|||
require "optparse"
|
||||
|
||||
module VagrantPlugins
|
||||
module CommandRDP
|
||||
class Command < Vagrant.plugin("2", :command)
|
||||
def self.synopsis
|
||||
"connects to machine via RDP"
|
||||
end
|
||||
|
||||
def execute
|
||||
opts = OptionParser.new do |o|
|
||||
o.banner = "Usage: vagrant rdp [options] [name]"
|
||||
end
|
||||
|
||||
# Parse the options and return if we don't have any target.
|
||||
argv = parse_options(opts)
|
||||
return if !argv
|
||||
|
||||
# Check if the host even supports RDP
|
||||
raise Errors::HostUnsupported if !@env.host.capability?(:rdp_client)
|
||||
|
||||
# Execute RDP if we can
|
||||
with_target_vms(argv, single_target: true) do |machine|
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
module VagrantPlugins
|
||||
module CommandRDP
|
||||
module Errors
|
||||
# A convenient superclass for all our errors.
|
||||
class RDPError < Vagrant::Errors::VagrantError
|
||||
error_namespace("vagrant_rdp.errors")
|
||||
end
|
||||
|
||||
class HostUnsupported < RDPError
|
||||
error_key(:host_unsupported)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,31 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module CommandRDP
|
||||
autoload :Errors, File.expand_path("../errors", __FILE__)
|
||||
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "rdp command"
|
||||
description <<-DESC
|
||||
The rdp command opens a remote desktop Window to the
|
||||
machine if it supports RDP.
|
||||
DESC
|
||||
|
||||
command("rdp") do
|
||||
require File.expand_path("../command", __FILE__)
|
||||
init!
|
||||
Command
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.init!
|
||||
return if defined?(@_init)
|
||||
I18n.load_path << File.expand_path(
|
||||
"templates/locales/command_rdp.yml", Vagrant.source_root)
|
||||
I18n.reload!
|
||||
@_init = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
en:
|
||||
vagrant_rdp:
|
||||
errors:
|
||||
host_unsupported: |-
|
||||
Vagrant doesn't support running an RDP client on your
|
||||
host OS. Currently only Windows is supported for RDP
|
||||
clients.
|
||||
|
||||
If you wish for the OS you're running to support launching
|
||||
an RDP client, please contribute this functionality back
|
||||
into Vagrant. At the very least, open an issue on how it
|
||||
could be done and we can handle the integration.
|
Loading…
Reference in New Issue