Class: Vagrant::Command::StatusCommand

Inherits:
NamedBase
  • Object
show all
Defined in:
lib/vagrant/command/status.rb

Instance Attribute Summary

Attributes inherited from Base

#env

Instance Method Summary collapse

Methods inherited from Base

#initialize, register

Methods included from Helpers

#initialize_environment, #target_vms

Constructor Details

This class inherits a constructor from Vagrant::Command::Base

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant/command/status.rb', line 6

def execute
  state = nil
  results = target_vms.collect do |vm|
    if vm.created?
      if vm.vm.accessible?
        state = vm.vm.state.to_s
      else
        state = "inaccessible"
      end
    else
      state = "not_created"
    end

    "#{vm.name.to_s.ljust(25)}#{state.gsub("_", " ")}"
  end

  state = target_vms.length == 1 ? state : "listing"

  env.ui.info(I18n.t("vagrant.commands.status.output",
              :states => results.join("\n"),
              :message => I18n.t("vagrant.commands.status.#{state}")),
              :prefix => false)
end