diff --git a/lib/vagrant/cli.rb b/lib/vagrant/cli.rb index 6c1b97a1e..76ebc9abe 100644 --- a/lib/vagrant/cli.rb +++ b/lib/vagrant/cli.rb @@ -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) diff --git a/lib/vagrant/plugin/v2/plugin.rb b/lib/vagrant/plugin/v2/plugin.rb index d9a6bfdb0..bacf891dc 100644 --- a/lib/vagrant/plugin/v2/plugin.rb +++ b/lib/vagrant/plugin/v2/plugin.rb @@ -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] diff --git a/test/unit/vagrant/plugin/v2/plugin_test.rb b/test/unit/vagrant/plugin/v2/plugin_test.rb index 6522aa54e..4a7a32feb 100644 --- a/test/unit/vagrant/plugin/v2/plugin_test.rb +++ b/test/unit/vagrant/plugin/v2/plugin_test.rb @@ -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| diff --git a/website/docs/source/v2/plugins/commands.html.md b/website/docs/source/v2/plugins/commands.html.md index 23cea5fcd..26b723d80 100644 --- a/website/docs/source/v2/plugins/commands.html.md +++ b/website/docs/source/v2/plugins/commands.html.md @@ -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.