diff --git a/plugins/commands/rdp/command.rb b/plugins/commands/rdp/command.rb new file mode 100644 index 000000000..4fd252f6f --- /dev/null +++ b/plugins/commands/rdp/command.rb @@ -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 diff --git a/plugins/commands/rdp/errors.rb b/plugins/commands/rdp/errors.rb new file mode 100644 index 000000000..0e58b4808 --- /dev/null +++ b/plugins/commands/rdp/errors.rb @@ -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 diff --git a/plugins/commands/rdp/plugin.rb b/plugins/commands/rdp/plugin.rb new file mode 100644 index 000000000..5cc00be78 --- /dev/null +++ b/plugins/commands/rdp/plugin.rb @@ -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 diff --git a/templates/locales/command_rdp.yml b/templates/locales/command_rdp.yml new file mode 100644 index 000000000..da597f485 --- /dev/null +++ b/templates/locales/command_rdp.yml @@ -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.