Class: VagrantPlugins::GlobalStatus::Command

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

Instance Method Summary collapse

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
29
30
# File 'lib/vagrant-global-status/command.rb', line 6

def execute
  options = {}

  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant global-status [--all]"

    o.on("-a", "--all", "Displays information about all machines (instead of just the active ones)") do |f|
      options[:all] = true
    end
  end

  @argv = parse_options(opts)
  return if !@argv

  registry = GlobalRegistry.new(@env.home_path.join('machine-environments.json'))
  registry.environments.each do |env|
    status = "#{env.status(options[:all])}"
    if not status == ""
      @env.ui.info "\n#{env.path}"
      @env.ui.info status 
    end
  end

  0
end