lib/bundler/cli.rb in bundler-1.0.0.rc.5 vs lib/bundler/cli.rb in bundler-1.0.0.rc.6
- old
+ new
@@ -21,10 +21,42 @@
check_unknown_options! unless ARGV.include?("exec") || ARGV.include?("config")
default_task :install
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
+ def help(cli = nil)
+ case cli
+ when "gemfile" then command = "gemfile.5"
+ when nil then command = "bundle"
+ else command = "bundle-#{cli}"
+ end
+
+ manpages = %w(
+ bundle
+ bundle-config
+ bundle-exec
+ bundle-install
+ bundle-package
+ bundle-update
+ gemfile.5)
+
+ if manpages.include?(command)
+ root = File.expand_path("../man", __FILE__)
+
+ if have_groff?
+ groff = "groff -Wall -mtty-char -mandoc -Tascii"
+ pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more'
+
+ Kernel.exec "#{groff} #{root}/#{command} | #{pager}"
+ else
+ puts File.read("#{root}/#{command}.txt")
+ end
+ else
+ super
+ end
+ end
+
desc "init", "Generates a Gemfile into the current working directory"
long_desc <<-D
Init generates a default Gemfile in the current working directory. When adding a
Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
dependency listed in the gemspec file to the newly created Gemfile.
@@ -294,13 +326,15 @@
begin
# Run
Kernel.exec(*ARGV)
rescue Errno::EACCES
Bundler.ui.error "bundler: not executable: #{ARGV.first}"
+ exit 126
rescue Errno::ENOENT
Bundler.ui.error "bundler: command not found: #{ARGV.first}"
Bundler.ui.warn "Install missing gem binaries with `bundle install`"
+ exit 127
end
end
desc "config NAME [VALUE]", "retrieve or set a configuration value"
long_desc <<-D
@@ -426,12 +460,13 @@
exit 1
end
constant_name = name.split('_').map{|p| p.capitalize}.join
constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/
+ constant_array = constant_name.split('::')
FileUtils.mkdir_p(File.join(target, 'lib', name))
- opts = {:name => name, :constant_name => constant_name}
+ opts = {:name => name, :constant_name => constant_name, :constant_array => constant_array}
template(File.join('newgem', 'Gemfile.tt'), File.join(target, 'Gemfile'), opts)
template(File.join('newgem', 'Rakefile.tt'), File.join(target, 'Rakefile'), opts)
template(File.join('newgem', 'gitignore.tt'), File.join(target, '.gitignore'), opts)
template(File.join('newgem', 'newgem.gemspec.tt'), File.join(target, "#{name}.gemspec"), opts)
template(File.join('newgem', 'lib', 'newgem.rb.tt'), File.join(target, 'lib', "#{name}.rb"), opts)
@@ -443,9 +478,14 @@
def self.source_root
File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end
private
+
+ def have_groff?
+ `which groff 2>#{NULL}`
+ $? == 0
+ end
def locate_gem(name)
spec = Bundler.load.specs.find{|s| s.name == name }
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
if spec.name == 'bundler'