class VagrantHosts::Command::List
Public Class Methods
Source
# File lib/vagrant-hosts/command/list.rb, line 10 def initialize(argv, env) @argv = argv @env = env @cmd_name = 'hosts list' split_argv end
Source
# File lib/vagrant-hosts/command/list.rb, line 6 def self.synopsis 'List private_network host info in /etc/hosts format' end
Public Instance Methods
Source
# File lib/vagrant-hosts/command/list.rb, line 18 def execute argv = parse_options(parser) @env.ui.info format_hosts 0 end
Private Instance Methods
Source
# File lib/vagrant-hosts/command/list.rb, line 28 def format_hosts vagrant_hosts(@env).inject('') do |str, (address, aliases)| str << "#{address} #{aliases.join(' ')}\n" end end
Source
# File lib/vagrant-hosts/command/list.rb, line 35 def parser OptionParser.new do |o| o.banner = "Usage: vagrant #{@cmd_name} [<args>]" o.separator '' o.on('-h', '--help', 'Display this help message') do puts o exit 0 end end end