Sha256: 50750198aa9e22d48222b1e89dbde0dc46dd7416b45c23a827ea7a251297b21e

Contents?: true

Size: 836 Bytes

Versions: 10

Compression:

Stored size: 836 Bytes

Contents

class VagrantHosts::Command::List < Vagrant.plugin('2', :command)

  include VagrantHosts::Command::Helpers
  include VagrantHosts::Addresses

  def self.synopsis
    'List private_network host info in /etc/hosts format'
  end

  def initialize(argv, env)
    @argv     = argv
    @env      = env
    @cmd_name = 'hosts list'

    split_argv
  end

  def execute

    argv = parse_options(parser)

    @env.ui.info format_hosts
    0
  end

  private

  def format_hosts
    vagrant_hosts(@env).inject('') do |str, (address, aliases)|
      str << "#{address} #{aliases.join(' ')}\n"
    end
  end


  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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vagrant-hosts-2.9.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.8.3 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.8.2 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.8.1 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.8.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.7.1 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.7.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.6.2 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.6.1 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.6.0 lib/vagrant-hosts/command/list.rb