vagrant status now uses strings.yml instead of hardcoding strings into the command

This commit is contained in:
Mitchell Hashimoto 2010-04-30 23:52:16 -07:00
parent 13c05de702
commit 1900d1faaa
3 changed files with 52 additions and 42 deletions

View File

@ -8,46 +8,30 @@ module Vagrant
description "Shows the status of the current environment."
def execute(args=[])
wrap_output do
if !env.root_path
puts <<-msg
No vagrant environment detected. Run `vagrant init` to setup a Vagrantfile
in the current directory to get started with Vagrant.
msg
elsif !env.vm
puts <<-msg
The environment has not yet been created. Run `vagrant up` to create the
environment.
msg
else
additional_msg = ""
if env.vm.vm.running?
additional_msg = <<-msg
To stop this VM, you can run `vagrant halt` to shut it down forcefully,
or you can run `vagrant suspend` to simply suspend the virtual machine.
In either case, to restart it again, simply run a `vagrant up`.
msg
elsif env.vm.vm.saved?
additional_msg = <<-msg
To resume this VM, simply run `vagrant up`.
msg
elsif env.vm.vm.powered_off?
additional_msg = <<-msg
To restart this VM, simply run `vagrant up`.
msg
end
string_key = nil
if !additional_msg.empty?
additional_msg.chomp!
additional_msg = "\n\n#{additional_msg}"
end
puts <<-msg
The environment has been created. The status of the current environment's
virtual machine is: "#{env.vm.vm.state}."#{additional_msg}
msg
if !env.root_path
string_key = :status_no_environment
elsif !env.vm
string_key = :status_not_created
else
additional_key = nil
if env.vm.vm.running?
additional_key = :status_created_running
elsif env.vm.vm.saved?
additional_key = :status_created_saved
elsif env.vm.vm.powered_off?
additional_key = :status_created_powered_off
end
string_key = [:status_created, {
:vm_state => env.vm.vm.state,
:additional_message => additional_key ? Translator.t(additional_key) : ""
}]
end
string_key = [string_key, {}] unless string_key.is_a?(Array)
wrap_output { puts Translator.t(*string_key) }
end
def options_spec(opts)

View File

@ -3,6 +3,32 @@
# In short, | means keep new lines, trim whitespace left and right
# The |- does the above, but trims the new line at the end of all text
#---------------------------------------------------------------------
# CATEGORY: Status Messages
#---------------------------------------------------------------------
:status_no_environment: |-
No vagrant environment detected. Run `vagrant init` to setup a Vagrantfile
in the current directory to get started with Vagrant.
:status_not_created: |-
The environment has not yet been created. Run `vagrant up` to create the
environment.
:status_created: |-
The environment has been created. The status of the current environment's
virtual machine is: "<%= vm_state %>"
<%= additional_message %>
:status_created_running: |-
To stop this VM, you can run `vagrant halt` to shut it down forcefully,
or you can run `vagrant suspend` to simply suspend the virtual machine.
In either case, to restart it again, simply run a `vagrant up`.
:status_created_saved: |-
To resume this VM, simply run `vagrant up`.
:status_created_powered_off: |-
To restart this VM, simply run `vagrant up`.
#---------------------------------------------------------------------
# CATEGORY: Error Messages
#---------------------------------------------------------------------
:box_already_exists: |-
This box appears to already exist! Please call `vagrant box remove <%= box_name %>`
and then try to add it again.

View File

@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Mitchell Hashimoto", "John Bender"]
s.date = %q{2010-04-29}
s.date = %q{2010-04-30}
s.default_executable = %q{vagrant}
s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
@ -91,19 +91,19 @@ Gem::Specification.new do |s|
"lib/vagrant/systems/base.rb",
"lib/vagrant/systems/linux.rb",
"lib/vagrant/util.rb",
"lib/vagrant/util/errors.rb",
"lib/vagrant/util/glob_loader.rb",
"lib/vagrant/util/platform.rb",
"lib/vagrant/util/progress_meter.rb",
"lib/vagrant/util/stacked_proc_runner.rb",
"lib/vagrant/util/template_renderer.rb",
"lib/vagrant/util/translator.rb",
"lib/vagrant/vm.rb",
"templates/Vagrantfile.erb",
"templates/chef_server_client.erb",
"templates/chef_solo_solo.erb",
"templates/errors.yml",
"templates/package_Vagrantfile.erb",
"templates/ssh_config.erb",
"templates/strings.yml",
"test/test_helper.rb",
"test/vagrant/actions/base_test.rb",
"test/vagrant/actions/box/add_test.rb",
@ -160,10 +160,10 @@ Gem::Specification.new do |s|
"test/vagrant/provisioners/chef_test.rb",
"test/vagrant/ssh_test.rb",
"test/vagrant/systems/linux_test.rb",
"test/vagrant/util/errors_test.rb",
"test/vagrant/util/progress_meter_test.rb",
"test/vagrant/util/stacked_proc_runner_test.rb",
"test/vagrant/util/template_renderer_test.rb",
"test/vagrant/util/translator_test.rb",
"test/vagrant/util_test.rb",
"test/vagrant/vm_test.rb",
"vagrant.gemspec"
@ -230,10 +230,10 @@ Gem::Specification.new do |s|
"test/vagrant/provisioners/chef_test.rb",
"test/vagrant/ssh_test.rb",
"test/vagrant/systems/linux_test.rb",
"test/vagrant/util/errors_test.rb",
"test/vagrant/util/progress_meter_test.rb",
"test/vagrant/util/stacked_proc_runner_test.rb",
"test/vagrant/util/template_renderer_test.rb",
"test/vagrant/util/translator_test.rb",
"test/vagrant/util_test.rb",
"test/vagrant/vm_test.rb"
]