Class: VagrantPort::Command
- Inherits:
-
Object
- Object
- VagrantPort::Command
- Defined in:
- lib/vagrant-port/command.rb
Defined Under Namespace
Classes: Settings
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-port/command.rb', line 4 def execute require "optparse" settings = Settings.new settings.machines = [] = OptionParser.new do |o| o. = "Query which host port is mapped to the given guest port.\n" \ "Usage: vagrant port <guest_port_number>" o.on("-m MACHINE", "The machine to query") do |value| settings.machines << value end end settings.machines = ["default"] if settings.machines.empty? argv = () if argv.nil? || argv.empty? puts .help return 1 end with_target_vms(settings.machines) do |machine| machine.provider.driver.read_forwarded_ports.each do |active, name, host, guest| puts host if argv.include?(guest.to_s) end end return 0 end |