diff --git a/lib/vagrant/cli.rb b/lib/vagrant/cli.rb index d1765dcce..db0f4fec6 100644 --- a/lib/vagrant/cli.rb +++ b/lib/vagrant/cli.rb @@ -13,12 +13,12 @@ module Vagrant if klass <= Command::GroupBase # A subclass of GroupBase is a subcommand, since it contains # many smaller commands within it. - desc usage, description + desc usage, description, opts subcommand name, klass elsif klass <= Command::Base # A subclass of Base is a single command, since it - # is invoked as a whole. - desc usage, description + # is invoked as a whole (as Thor::Group) + desc usage, description, opts define_method(name) { |*args| invoke klass, args } end diff --git a/lib/vagrant/command/upgrade_to_060.rb b/lib/vagrant/command/upgrade_to_060.rb new file mode 100644 index 000000000..3c34adccf --- /dev/null +++ b/lib/vagrant/command/upgrade_to_060.rb @@ -0,0 +1,34 @@ +module Vagrant + module Command + class UpgradeTo060Command < Base + desc "Upgrade pre-0.6.0 environment to 0.6.0" + register "upgrade_to_060", :hide => true + + def execute + @env.ui.warn "vagrant.commands.upgrade_to_060.info", :_prefix => false + @env.ui.warn "", :_translate => false, :_prefix => false + if !@env.ui.yes? "vagrant.commands.upgrade_to_060.ask", :_prefix => false, :_color => :yellow + @env.ui.info "vagrant.commands.upgrade_to_060.quit", :_prefix => false + return + end + + if !@env.local_data.empty? + # Gather the previously set virtual machines into a single + # active hash + active = @env.local_data.inject({}) do |acc, data| + key, uuid = data + acc[key.to_sym] = uuid + acc + end + + # Set the active hash to the active list and save it + @env.local_data.clear + @env.local_data[:active] = active + @env.local_data.commit + end + + @env.ui.confirm "vagrant.commands.upgrade_to_060.complete", :_prefix => false + end + end + end +end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 08306002a..3dad59a6f 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -126,6 +126,16 @@ en: VM, run `vagrant status NAME`. up: vm_created: "VM already created. Booting if its not already running..." + upgrade_to_060: + info: |- + This command will upgrade the current environment from a pre-0.6.0 + environment to a 0.6.x compatible environment. Running this command + on a 0.6.0 environment may cause corrupt virtual machines, however, + so verify now that this is your first time running this command and + that this environment was created pre-0.6.0. + ask: "Are you sure you want to execute this command?" + quit: "Not executing this command by user request. Quitting..." + complete: "Environment upgraded to 0.6.0 successfully." version: output: "Vagrant version %{version}"