Make commands API more consistent with both single and group commands
This commit is contained in:
parent
4a25acaad8
commit
5316a520c6
|
@ -26,10 +26,8 @@ module Vagrant
|
|||
# given name. The name will be used for accessing it from the CLI,
|
||||
# so if you name it "lamp", then the command to invoke this
|
||||
# will be `vagrant lamp`.
|
||||
#
|
||||
# The description added to the class via the `desc` method will be
|
||||
# used as a description for the command.
|
||||
def self.register(usage, opts=nil)
|
||||
def self.register(usage, description, opts=nil)
|
||||
desc description
|
||||
CLI.register(self, extract_name_from_usage(usage), usage, desc, opts)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class DestroyCommand < NamedBase
|
||||
desc "Destroy the environment, deleting the created virtual machines"
|
||||
register "destroy"
|
||||
register "destroy", "Destroy the environment, deleting the created virtual machines"
|
||||
|
||||
def execute
|
||||
target_vms.each do |vm|
|
||||
|
|
|
@ -18,9 +18,6 @@ module Vagrant
|
|||
# usage. The usage will be used for accessing it from the CLI,
|
||||
# so if you give it a usage of `lamp [subcommand]`, then the command
|
||||
# to invoke this will be `vagrant lamp` (with a subcommand).
|
||||
#
|
||||
# Additionally, unlike {Base}, a description must be specified to
|
||||
# this register command, since there is no class-wide description.
|
||||
def self.register(usage, description, opts=nil)
|
||||
CLI.register(self, Base.extract_name_from_usage(usage), usage, description, opts)
|
||||
end
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class HaltCommand < NamedBase
|
||||
desc "Halt the running VMs in the environment"
|
||||
class_option :force, :type => :boolean, :default => false, :aliases => "-f"
|
||||
register "halt"
|
||||
register "halt", "Halt the running VMs in the environment"
|
||||
|
||||
def execute
|
||||
target_vms.each do |vm|
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class InitCommand < Base
|
||||
desc "Initializes the current folder for Vagrant usage"
|
||||
argument :box_name, :type => :string, :optional => true, :default => "base"
|
||||
argument :box_url, :type => :string, :optional => true
|
||||
source_root File.expand_path("templates/commands/init", Vagrant.source_root)
|
||||
register "init [box_name] [box_url]"
|
||||
register "init [box_name] [box_url]", "Initializes the current folder for Vagrant usage"
|
||||
|
||||
def execute
|
||||
template "Vagrantfile.erb", "Vagrantfile"
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class PackageCommand < NamedBase
|
||||
desc "Package a Vagrant environment for distribution"
|
||||
class_option :base, :type => :string, :default => nil
|
||||
class_option :output, :type => :string, :default => nil
|
||||
class_option :include, :type => :array, :default => nil
|
||||
class_option :vagrantfile, :type => :string, :default => nil
|
||||
register "package"
|
||||
register "package", "Package a Vagrant environment for distribution"
|
||||
|
||||
def execute
|
||||
return package_base if options[:base]
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class ProvisionCommand < NamedBase
|
||||
desc "Rerun the provisioning scripts on a running VM"
|
||||
register "provision"
|
||||
register "provision", "Rerun the provisioning scripts on a running VM"
|
||||
|
||||
def execute
|
||||
target_vms.each do |vm|
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class ReloadCommand < NamedBase
|
||||
desc "Reload the environment, halting it then restarting it."
|
||||
register "reload"
|
||||
register "reload", "Reload the environment, halting it then restarting it."
|
||||
|
||||
def execute
|
||||
target_vms.each do |vm|
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class ResumeCommand < NamedBase
|
||||
desc "Resume a suspended Vagrant environment."
|
||||
register "resume"
|
||||
register "resume", "Resume a suspended Vagrant environment."
|
||||
|
||||
def execute
|
||||
target_vms.each do |vm|
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class SSHCommand < NamedBase
|
||||
desc "SSH into the currently running Vagrant environment."
|
||||
class_option :execute, :type => :string, :default => false, :aliases => "-e"
|
||||
register "ssh"
|
||||
register "ssh", "SSH into the currently running Vagrant environment."
|
||||
|
||||
def execute
|
||||
if options[:execute]
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class SSHConfigCommand < NamedBase
|
||||
desc "outputs .ssh/config valid syntax for connecting to this environment via ssh"
|
||||
class_option :host, :type => :string, :default => nil, :aliases => "-h"
|
||||
register "ssh_config"
|
||||
register "ssh_config", "outputs .ssh/config valid syntax for connecting to this environment via ssh"
|
||||
|
||||
def execute
|
||||
raise MultiVMTargetRequired.new(:command => "ssh_config") if target_vms.length > 1
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class StatusCommand < Base
|
||||
desc "Shows the status of the current Vagrant environment."
|
||||
argument :name, :type => :string, :optional => true
|
||||
register "status"
|
||||
register "status", "Shows the status of the current Vagrant environment."
|
||||
|
||||
def route
|
||||
state = nil
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class SuspendCommand < NamedBase
|
||||
desc "Suspend a running Vagrant environment."
|
||||
register "suspend"
|
||||
register "suspend", "Suspend a running Vagrant environment."
|
||||
|
||||
def execute
|
||||
target_vms.each do |vm|
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class UpCommand < NamedBase
|
||||
desc "Creates the Vagrant environment"
|
||||
class_option :provision, :type => :boolean, :default => true
|
||||
register "up"
|
||||
register "up", "Creates the Vagrant environment"
|
||||
|
||||
def execute
|
||||
# TODO: Make the options[:provision] actually mean something
|
||||
|
|
|
@ -3,8 +3,7 @@ require 'fileutils'
|
|||
module Vagrant
|
||||
module Command
|
||||
class UpgradeTo060Command < Base
|
||||
desc "Upgrade pre-0.6.0 environment to 0.6.0"
|
||||
register "upgrade_to_060", :hide => true
|
||||
register "upgrade_to_060", "Upgrade pre-0.6.0 environment to 0.6.0", :hide => true
|
||||
|
||||
def execute
|
||||
@env.ui.warn "vagrant.commands.upgrade_to_060.info", :_prefix => false
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class VersionCommand < Base
|
||||
desc "Prints the Vagrant version information"
|
||||
register "version", :alias => %w(-v --version)
|
||||
register "version", "Prints the Vagrant version information", :alias => %w(-v --version)
|
||||
|
||||
def version
|
||||
env.ui.info("vagrant.commands.version.output",
|
||||
|
|
Loading…
Reference in New Issue