lib/bundler/cli.rb in bundler-1.2.0.pre.1 vs lib/bundler/cli.rb in bundler-1.2.0.rc

- old
+ new

@@ -12,11 +12,11 @@ Bundler.ui = UI::Shell.new(the_shell) Bundler.ui.debug! if options["verbose"] Bundler.rubygems.ui = UI::RGProxy.new(Bundler.ui) end - check_unknown_options! + check_unknown_options!(:except => [:config, :exec]) default_task :install class_option "no-color", :type => :boolean, :banner => "Disable colorization in output" class_option "verbose", :type => :boolean, :banner => "Enable verbose output mode", :aliases => "-V" @@ -92,10 +92,12 @@ D method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile" method_option "path", :type => :string, :banner => "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine" + method_option "dry-run", :type => :boolean, :default => false, :banner => + "Lock the Gemfile" def check ENV['BUNDLE_GEMFILE'] = File.expand_path(options[:gemfile]) if options[:gemfile] Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path] begin @@ -115,11 +117,11 @@ exit 1 elsif !Bundler.default_lockfile.exist? && Bundler.settings[:frozen] Bundler.ui.error "This bundle has been frozen, but there is no Gemfile.lock present" exit 1 else - Bundler.load.lock + Bundler.load.lock unless options[:"dry-run"] Bundler.ui.info "The Gemfile's dependencies are satisfied" end end desc "install", "Install the current environment to the system" @@ -414,24 +416,22 @@ long_desc <<-D Exec runs a command, providing it access to the gems in the bundle. While using bundle exec you can require and call the bundled gems as if they were installed into the systemwide Rubygems repository. D - def exec(*) - ARGV.shift # remove "exec" - + def exec(*args) Bundler.definition.validate_ruby! Bundler.load.setup_environment begin # Run - Kernel.exec(*ARGV) + Kernel.exec(*args) rescue Errno::EACCES - Bundler.ui.error "bundler: not executable: #{ARGV.first}" + Bundler.ui.error "bundler: not executable: #{args.first}" exit 126 rescue Errno::ENOENT - Bundler.ui.error "bundler: command not found: #{ARGV.first}" + Bundler.ui.error "bundler: command not found: #{args.first}" Bundler.ui.warn "Install missing gem executables with `bundle install`" exit 127 rescue ArgumentError Bundler.ui.error "bundler: exec needs a command to run" exit 128 @@ -448,18 +448,15 @@ If a global setting is superceded by local configuration, this command will show the current value, as well as any superceded values and where they were specified. D - def config(*) - values = ARGV.dup - values.shift # remove config + def config(*args) + peek = args.shift - peek = values.shift - if peek && peek =~ /^\-\-/ - name, scope = values.shift, $' + name, scope = args.shift, $' else name, scope = peek, "global" end unless name @@ -480,11 +477,11 @@ case scope when "delete" Bundler.settings.set_local(name, nil) Bundler.settings.set_global(name, nil) when "local", "global" - if values.empty? + if args.empty? Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used" with_padding do Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line } end return @@ -510,11 +507,11 @@ if scope == "local" && local = locations[:local] Bundler.ui.info "You are replacing the current local value of #{name}, which is currently #{local.inspect}" end - Bundler.settings.send("set_#{scope}", name, values.join(" ")) + Bundler.settings.send("set_#{scope}", name, args.join(" ")) else Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global." exit 1 end end @@ -598,11 +595,11 @@ :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name, :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email } 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/LICENSE.tt"), File.join(target, "LICENSE"), opts) + template(File.join("newgem/LICENSE.txt.tt"), File.join(target, "LICENSE.txt"), opts) template(File.join("newgem/README.md.tt"), File.join(target, "README.md"), 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) template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts) @@ -665,12 +662,12 @@ end private def setup_cache_all - if options.key?("all") - Bundler.settings[:cache_all] = options[:all] || nil - elsif Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } + Bundler.settings[:cache_all] = options[:all] if options.key?("all") + + if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all] Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \ "to package them as well, please pass the --all flag. This will be the default " \ "on Bundler 2.0." end end