Class: MediaWikiVagrant::ForwardPort
- Includes:
- PluginEnvironment, SettingsPlugin
- Defined in:
- lib/mediawiki-vagrant/forward_port.rb
Overview
Configures port forwarding from the host to the guest VM.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from PluginEnvironment
#initialize, #interactive_out?
Class Method Details
.synopsis ⇒ Object
13 14 15 |
# File 'lib/mediawiki-vagrant/forward_port.rb', line 13 def self.synopsis 'configures port forwarding from the host to the guest VM' end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mediawiki-vagrant/forward_port.rb', line 17 def execute = { list: false, remove: [] } opts = OptionParser.new do |o| o. = 'Usage: vagrant forward-port [options] [host-port guest-port [...]]' o.separator '' o.separator 'Options:' o.separator '' o.on('-l', '--list', 'List currently forwarded ports') do [:list] = true end o.on('-r', '--remove PORT', 'Remove forwarding for the given host port') do |port| [:remove] << port end end argv = (opts) return unless argv if [:list] list elsif [:remove].any? remove([:remove].map(&:to_i)) elsif argv.length == 2 forward(*(argv.map(&:to_i))) else @env.ui.error opts return 1 end 0 end |