lib/bundler/cli.rb in bundler-1.14.0.pre.1 vs lib/bundler/cli.rb in bundler-1.14.0.pre.2

- old
+ new

@@ -399,10 +399,12 @@ def viz require "bundler/cli/viz" Viz.new(options.dup).run end + old_gem = instance_method(:gem) + desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem" method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library." method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config gem.coc true`." method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR", :lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? }, @@ -410,12 +412,32 @@ method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code" method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config gem.mit true`." method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec", :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config gem.test rspec`." def gem(name) - require "bundler/cli/gem" - Gem.new(options, name, self).run end + + commands["gem"].tap do |gem_command| + def gem_command.run(instance, args = []) + arity = 1 # name + + require "bundler/cli/gem" + cmd_args = args + [instance] + cmd_args.unshift(instance.options) + + cmd = begin + Gem.new(*cmd_args) + rescue ArgumentError => e + instance.class.handle_argument_error(self, e, args, arity) + end + + cmd.run + end + end + + undef_method(:gem) + define_method(:gem, old_gem) + private :gem def self.source_root File.expand_path(File.join(File.dirname(__FILE__), "templates")) end