core: output synopsis with command [GH-2249]
This commit is contained in:
parent
844c672911
commit
97389d4255
|
@ -55,13 +55,16 @@ module Vagrant
|
||||||
|
|
||||||
# Add the available subcommands as separators in order to print them
|
# Add the available subcommands as separators in order to print them
|
||||||
# out as well.
|
# out as well.
|
||||||
keys = []
|
commands = {}
|
||||||
Vagrant.plugin("2").manager.commands.each do |key, _|
|
longest = 0
|
||||||
keys << key
|
Vagrant.plugin("2").manager.commands.each do |key, klass|
|
||||||
|
key = key.to_s
|
||||||
|
commands[key] = klass.synopsis
|
||||||
|
longest = key.length if key.length > longest
|
||||||
end
|
end
|
||||||
|
|
||||||
keys.sort.each do |key|
|
commands.keys.sort.each do |key|
|
||||||
o.separator " #{key}"
|
o.separator " #{key.ljust(longest+2)} #{commands[key]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
o.separator ""
|
o.separator ""
|
||||||
|
|
|
@ -9,6 +9,14 @@ module Vagrant
|
||||||
class Command
|
class Command
|
||||||
include Util::SafePuts
|
include Util::SafePuts
|
||||||
|
|
||||||
|
# This should return a brief (60 characters or less) synopsis of what
|
||||||
|
# this command does. It will be used in the output of the help.
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
def self.synopsis
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(argv, env)
|
def initialize(argv, env)
|
||||||
@argv = argv
|
@argv = argv
|
||||||
@env = env
|
@env = env
|
||||||
|
|
|
@ -4,6 +4,10 @@ module VagrantPlugins
|
||||||
module CommandBox
|
module CommandBox
|
||||||
module Command
|
module Command
|
||||||
class Root < Vagrant.plugin("2", :command)
|
class Root < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"manages boxes: installation, removal, etc."
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(argv, env)
|
def initialize(argv, env)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandDestroy
|
module CommandDestroy
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"stops and deletes all traces of the vagrant machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
options[:force] = false
|
options[:force] = false
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandHalt
|
module CommandHalt
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"stops the vagrant machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
options[:force] = false
|
options[:force] = false
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandHelp
|
module CommandHelp
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"shows the help for a subcommand"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
return @env.cli([]) if @argv.empty?
|
return @env.cli([]) if @argv.empty?
|
||||||
@env.cli([@argv[0], "-h"])
|
@env.cli([@argv[0], "-h"])
|
||||||
|
|
|
@ -5,11 +5,13 @@ require 'vagrant/util/template_renderer'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandInit
|
module CommandInit
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
def execute
|
def self.synopsis
|
||||||
options = {}
|
"initializes a new Vagrant environment by creating a Vagrantfile"
|
||||||
|
end
|
||||||
|
|
||||||
opts = OptionParser.new do |opts|
|
def execute
|
||||||
opts.banner = "Usage: vagrant init [box-name] [box-url]"
|
opts = OptionParser.new do |o|
|
||||||
|
o.banner = "Usage: vagrant init [box-name] [box-url]"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parse the options
|
# Parse the options
|
||||||
|
@ -34,7 +36,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Success, exit status 0
|
# Success, exit status 0
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandPackage
|
module CommandPackage
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"packages a running vagrant environment into a box"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@ module VagrantPlugins
|
||||||
module CommandPlugin
|
module CommandPlugin
|
||||||
module Command
|
module Command
|
||||||
class Root < Vagrant.plugin("2", :command)
|
class Root < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"manages plugins: install, uninstall, update, etc."
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(argv, env)
|
def initialize(argv, env)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandProvision
|
module CommandProvision
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"provisions the vagrant machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
options[:provision_types] = nil
|
options[:provision_types] = nil
|
||||||
|
|
|
@ -11,6 +11,10 @@ module VagrantPlugins
|
||||||
# to this.
|
# to this.
|
||||||
include VagrantPlugins::CommandUp::StartMixins
|
include VagrantPlugins::CommandUp::StartMixins
|
||||||
|
|
||||||
|
def self.synopsis
|
||||||
|
"restarts vagrant machine, loads new Vagrantfile configuration"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
options[:provision_ignore_sentinel] = false
|
options[:provision_ignore_sentinel] = false
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandResume
|
module CommandResume
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"resume a suspended vagrant machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: vagrant resume [vm-name]"
|
o.banner = "Usage: vagrant resume [vm-name]"
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandSSH
|
module CommandSSH
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"connects to machine via SSH"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ module VagrantPlugins
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
include Vagrant::Util::SafePuts
|
include Vagrant::Util::SafePuts
|
||||||
|
|
||||||
|
def self.synopsis
|
||||||
|
"outputs OpenSSH valid configuration to connect to the machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandStatus
|
module CommandStatus
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"outputs status of the vagrant machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: vagrant status [machine-name]"
|
o.banner = "Usage: vagrant status [machine-name]"
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'optparse'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module CommandSuspend
|
module CommandSuspend
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
|
def self.synopsis
|
||||||
|
"suspends the machine"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: vagrant suspend [vm-name]"
|
o.banner = "Usage: vagrant suspend [vm-name]"
|
||||||
|
|
|
@ -9,6 +9,10 @@ module VagrantPlugins
|
||||||
class Command < Vagrant.plugin("2", :command)
|
class Command < Vagrant.plugin("2", :command)
|
||||||
include StartMixins
|
include StartMixins
|
||||||
|
|
||||||
|
def self.synopsis
|
||||||
|
"starts and provisions the vagrant environment"
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
options = {}
|
options = {}
|
||||||
options[:destroy_on_error] = true
|
options[:destroy_on_error] = true
|
||||||
|
|
Loading…
Reference in New Issue