summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Fischbach <mail@timfischbach.de>2015-08-04 08:45:54 +0200
committerTim Fischbach <mail@timfischbach.de>2015-08-04 09:18:09 +0200
commitb37d3087b9bbf89bc6d1d4ae6d0b977c20eac053 (patch)
tree554a98b3ba0cb7a7d7c22d26d4827b4c7bf278b4
parent7cad928d08c75a7eeed0a4a97199a4f64b5e0ed7 (diff)
downloadbundler-b37d3087b9bbf89bc6d1d4ae6d0b977c20eac053.tar.gz
Add command plugin support to help command
Bundler already delegates to executables of the form `bundler-<command>` when called as `bundle <command>` with an unknown command. Allow viewing help entries for such command plugins by turning calls of the form `bundle help <command>` into `bundler-<command> --help`.
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--spec/commands/help_spec.rb13
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index f4cd6c0e5f..e79cd5b145 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -66,6 +66,8 @@ module Bundler
else
puts File.read("#{root}/#{command}.txt")
end
+ elsif command_path = Bundler.which("bundler-#{cli}")
+ Kernel.exec(command_path, "--help")
else
super
end
diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb
index 739f62224e..80a55809d3 100644
--- a/spec/commands/help_spec.rb
+++ b/spec/commands/help_spec.rb
@@ -36,4 +36,17 @@ describe "bundle help" do
bundle "help check"
expect(out).to include("Check searches the local machine")
end
+
+ it "looks for a binary and executes it with --help option if it's named bundler-<task>" do
+ File.open(tmp("bundler-testtasks"), "w", 0755) do |f|
+ f.puts "#!/usr/bin/env ruby\nputs ARGV.join(' ')\n"
+ end
+
+ with_path_as(tmp) do
+ bundle "help testtasks"
+ end
+
+ expect(exitstatus).to be_zero if exitstatus
+ expect(out).to eq("--help")
+ end
end