Some new APIs were added to the easy command operations. `info`, `error`, and `success` are simple ways to output messages to the UI without resorting to "puts" in Ruby, since the Vagrant UI object is the idiomatic way to do communication with the world. Additionally, `argv` was added which gives commands access to the command-line arguments that are remaining that does not include the vagrant binary or subcommand. Also, behavior was changed: Previously, easy commands would run for every target VM. Now, it is only run once with the primary VM. In the next commit, I plan on adding a new flag that signifies an easy command is meant to work with a named VM.
30 lines
943 B
Ruby
30 lines
943 B
Ruby
module Vagrant
|
|
module Easy
|
|
autoload :CommandBase, "vagrant/easy/command_base"
|
|
autoload :CommandAPI, "vagrant/easy/command_api"
|
|
autoload :Operations, "vagrant/easy/operations"
|
|
|
|
# This creates a new easy command. This typically is not called
|
|
# directly. Instead, the plugin interface's `easy_command` is
|
|
# used to create one of these.
|
|
def self.create_command(name, &block)
|
|
# Create a new command class for this command, and return it
|
|
command = Class.new(CommandBase)
|
|
command.configure(name, &block)
|
|
command
|
|
end
|
|
|
|
# This creates a new easy hook. This should not be called by the
|
|
# general public. Instead, use the plugin interface.
|
|
#
|
|
# @return [Proc]
|
|
def self.create_hook(&block)
|
|
# Create a lambda which simply calls the plugin with the operations
|
|
lambda do |env|
|
|
ops = Operations.new(env[:vm])
|
|
block.call(ops)
|
|
end
|
|
end
|
|
end
|
|
end
|