core: default commands to primary
This commit is contained in:
parent
f05388349c
commit
08b1aee00d
|
@ -53,7 +53,7 @@ module Vagrant
|
|||
o.on("-v", "--version", "Print the version and exit.")
|
||||
o.on("-h", "--help", "Print this help.")
|
||||
o.separator ""
|
||||
o.separator "Available subcommands:"
|
||||
o.separator "Common subcommands:"
|
||||
|
||||
# Add the available subcommands as separators in order to print them
|
||||
# out as well.
|
||||
|
@ -77,6 +77,10 @@ module Vagrant
|
|||
|
||||
o.separator ""
|
||||
o.separator "For help on any individual command run `vagrant COMMAND -h`"
|
||||
o.separator ""
|
||||
o.separator "Additional subcommands are available, but are either more advanced"
|
||||
o.separator "or not commonly used. To see all subcommands, run the command"
|
||||
o.separator "`vagrant list-commands`."
|
||||
end
|
||||
|
||||
@env.ui.info(opts.help, :prefix => false)
|
||||
|
|
|
@ -87,6 +87,9 @@ module Vagrant
|
|||
raise InvalidCommandName, "Commands can only contain letters, numbers, and hyphens"
|
||||
end
|
||||
|
||||
# By default, the command is primary
|
||||
opts[:primary] = true if !opts.has_key?(:primary)
|
||||
|
||||
# Register the command
|
||||
components.commands.register(name.to_sym) do
|
||||
[block, opts]
|
||||
|
|
|
@ -64,9 +64,17 @@ describe Vagrant::Plugin::V2::Plugin do
|
|||
|
||||
expect(plugin.components.commands.keys).to be_include(:foo)
|
||||
expect(plugin.components.commands[:foo][0].call).to eql("bar")
|
||||
expect(plugin.components.commands[:foo][1]).to eql({
|
||||
opt: :bar,
|
||||
})
|
||||
expect(plugin.components.commands[:foo][1][:opt]).to eql(:bar)
|
||||
end
|
||||
|
||||
it "should register commands as primary by default" do
|
||||
plugin = Class.new(described_class) do
|
||||
command("foo") { "bar" }
|
||||
command("bar", primary: false) { "bar" }
|
||||
end
|
||||
|
||||
expect(plugin.components.commands[:foo][1][:primary]).to be_true
|
||||
expect(plugin.components.commands[:bar][1][:primary]).to be_false
|
||||
end
|
||||
|
||||
["spaces bad", "sym^bols"].each do |bad|
|
||||
|
|
|
@ -36,7 +36,7 @@ implements the `Vagrant.plugin(2, "command")` interface.
|
|||
|
||||
You can also define _non-primary commands_. These commands do not show
|
||||
up in the `vagrant -h` output. They only show up if the user explicitly
|
||||
does a `vagrant help commands` which shows the full listing of available
|
||||
does a `vagrant list-commands` which shows the full listing of available
|
||||
commands. This is useful for highly specific commands or plugins that a
|
||||
beginner to Vagrant would not be using anyways. Vagrant itself uses non-primary
|
||||
commands to expose some internal functions, as well.
|
||||
|
|
Loading…
Reference in New Issue