commands/rdp: support extra args to RDP client [GH-3686]

This commit is contained in:
Mitchell Hashimoto 2014-05-07 18:32:20 -07:00
parent 9e09616d91
commit e1815a13e8
3 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,9 @@
## 1.6.2 (unreleased)
IMPROVEMENTS:
- command/rdp: Args after "--" are passed directly through to the
RDP client. [GH-3686]
## 1.6.1 (May 7, 2014)

View File

@ -8,8 +8,18 @@ module VagrantPlugins
end
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant rdp [options] [name]"
o.banner = "Usage: vagrant rdp [options] [name] [-- extra args]"
end
# Parse out the extra args to send to the RDP client, which
# is everything after the "--"
split_index = @argv.index("--")
if split_index
options[:extra_args] = @argv.drop(split_index + 1)
@argv = @argv.take(split_index)
end
# Parse the options and return if we don't have any target.
@ -29,6 +39,9 @@ module VagrantPlugins
rdp_info = get_rdp_info(machine)
raise Errors::RDPUndetected if !rdp_info
# Extra arguments if we have any
rdp_info[:extra_args] = options[:extra_args]
machine.ui.detail(
"Address: #{rdp_info[:host]}:#{rdp_info[:port]}")
machine.ui.detail("Username: #{rdp_info[:username]}")

View File

@ -22,8 +22,14 @@ module VagrantPlugins
end
config.close
# Build up the args to mstsc
args = [config.path]
if rdp_info[:extra_args]
args = rdp_info[:extra_args] + args
end
# Launch it
Vagrant::Util::PowerShell.execute("mstsc", config.path)
Vagrant::Util::PowerShell.execute("mstsc", *args)
ensure
config.close if config
end