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