`vagrant status`
This commit is contained in:
parent
1176c65138
commit
780722386b
|
@ -102,6 +102,7 @@ Vagrant.commands.register(:reload) { Vagrant::Command::Reload }
|
|||
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
||||
Vagrant.commands.register(:ssh) { Vagrant::Command::SSH }
|
||||
Vagrant.commands.register(:"ssh-config") { Vagrant::Command::SSHConfig }
|
||||
Vagrant.commands.register(:status) { Vagrant::Command::Status }
|
||||
Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend }
|
||||
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ module Vagrant
|
|||
autoload :Resume, 'vagrant/command/resume'
|
||||
autoload :SSH, 'vagrant/command/ssh'
|
||||
autoload :SSHConfig, 'vagrant/command/ssh_config'
|
||||
autoload :Status, 'vagrant/command/status'
|
||||
autoload :Suspend, 'vagrant/command/suspend'
|
||||
autoload :Up, 'vagrant/command/up'
|
||||
end
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
require 'optparse'
|
||||
|
||||
module Vagrant
|
||||
module Command
|
||||
class StatusCommand < NamedBase
|
||||
register "status", "Shows the status of the current Vagrant environment."
|
||||
|
||||
class Status < Base
|
||||
def execute
|
||||
options = {}
|
||||
|
||||
opts = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: vagrant status [vm-name]"
|
||||
end
|
||||
|
||||
# Parse the options
|
||||
argv = parse_options(opts)
|
||||
return if !argv
|
||||
|
||||
state = nil
|
||||
results = target_vms.collect do |vm|
|
||||
results = []
|
||||
with_target_vms(argv[0]) do |vm|
|
||||
if vm.created?
|
||||
if vm.vm.accessible?
|
||||
state = vm.vm.state.to_s
|
||||
|
@ -16,15 +27,15 @@ module Vagrant
|
|||
state = "not_created"
|
||||
end
|
||||
|
||||
"#{vm.name.to_s.ljust(25)}#{state.gsub("_", " ")}"
|
||||
results << "#{vm.name.to_s.ljust(25)}#{state.gsub("_", " ")}"
|
||||
end
|
||||
|
||||
state = target_vms.length == 1 ? state : "listing"
|
||||
state = results.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)
|
||||
@env.ui.info(I18n.t("vagrant.commands.status.output",
|
||||
:states => results.join("\n"),
|
||||
:message => I18n.t("vagrant.commands.status.#{state}")),
|
||||
:prefix => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue