Mitchell Hashimoto 00aba5ac03 Plugin easy commands.
Easy commands are well... easy! They don't offer the full power of
creating a completely custom command class, but they let you do the
basics (what almost everyone needs) with minimal fuss. Example:

class MyPlugin < Vagrant.plugin("1")
  name "my-plugin"

  easy_command "foo" do |action|
    puts "HELLO!"
  end
end

NOTE: The "action" stuff isn't done yet, but will be soon!
2012-05-05 18:57:29 -07:00

40 lines
1016 B
Ruby

require 'optparse'
module VagrantPlugins
module CommandReload
class Command < Vagrant::Command::Base
# We assume that the `up` plugin exists and that we'll have access
# to this.
include VagrantPlugins::CommandUp::StartMixins
def execute
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant reload [vm-name]"
opts.separator ""
build_start_options(opts, options)
end
# Parse the options
argv = parse_options(opts)
return if !argv
@logger.debug("'reload' each target VM...")
with_target_vms(argv) do |vm|
if vm.created?
@logger.info("Reloading: #{vm.name}")
vm.reload(options)
else
@logger.info("Not created: #{vm.name}. Not reloading.")
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end
end