Sha256: 5d50743efe36f8ad4473502c24ffe7f2a9bed7080b4d2c3b2f4715e412d1b90e

Contents?: true

Size: 751 Bytes

Versions: 14

Compression:

Stored size: 751 Bytes

Contents

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

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

  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

14 entries across 14 versions & 1 rubygems

Version Path
vagrant-hosts-2.5.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.4.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.3.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.2.4 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.2.3 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.2.2 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.2.1 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.2.0 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.1.5 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.1.4 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.1.3 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.1.2 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.1.1 lib/vagrant-hosts/command/list.rb
vagrant-hosts-2.1.0 lib/vagrant-hosts/command/list.rb