class Bundler::CLI

def check

def check
  env = Bundler.load
  # Check top level dependencies
  missing = env.dependencies.select { |d| env.index.search(d).empty? }
  if missing.any?
    puts "The following dependencies are missing"
    missing.each do |d|
      puts "  * #{d}"
    end
  else
    env.specs
    puts "The Gemfile's dependencies are satisfied"
  end
end

def exec(*)

def exec(*)
  ARGV.delete('exec')
  ENV["RUBYOPT"] = %W(
    -I#{File.expand_path('../..', __FILE__)}
    -rbundler/setup
    #{ENV["RUBYOPT"]}
  ).compact.join(' ')
  Kernel.exec *ARGV
end

def init

def init
  if File.exist?("Gemfile")
    puts "Gemfile already exists at #{Dir.pwd}/Gemfile"
  else
    puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
    FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile')
  end
end

def initialize(*)

def initialize(*)
  super
  Bundler.ui = UI::Shell.new(shell)
  Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui)
end

def install(path = nil)

def install(path = nil)
  opts = options.dup
  opts[:without] ||= []
  opts[:without].map! { |g| g.to_sym }
  Bundler.settings[:path] = path if path
  Installer.install(Bundler.root, Bundler.definition, opts)
end

def lock

def lock
  if File.exist?("#{Bundler.root}/Gemfile.lock")
    Bundler.ui.info("The bundle is already locked, relocking.")
    `rm #{Bundler.root}/Gemfile.lock`
  end
  environment = Bundler.load
  environment.lock
end

def pack

def pack
  environment = Bundler.load
  environment.pack
end

def show

def show
  environment = Bundler.load
  Bundler.ui.info "Gems included by the bundle:"
  environment.specs.sort_by { |s| s.name }.each do |s|
    Bundler.ui.info "  * #{s.name} (#{s.version})"
  end
end

def unlock

def unlock
  environment = Bundler.load
  environment.unlock
end