aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/vendor/bundler/lib/bundler/cli.rb
blob: df9181fbc46e7b4c066aabf6ad492d941517064a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require "optparse"

module Bundler
  class CLI
    def self.run(command, options = {})
      new(options).run(command)
    rescue DefaultManifestNotFound => e
      Bundler.logger.error "Could not find a Gemfile to use"
      exit 2
    rescue InvalidEnvironmentName => e
      Bundler.logger.error "Gemfile error: #{e.message}"
      exit
    rescue InvalidRepository => e
      Bundler.logger.error e.message
      exit
    rescue VersionConflict => e
      Bundler.logger.error e.message
      exit
    rescue GemNotFound => e
      Bundler.logger.error e.message
      exit
    end

    def initialize(options)
      @options = options
      @manifest = Bundler::Environment.load(@options[:manifest])
    end

    def bundle
      @manifest.install(@options[:update])
    end

    def exec
      @manifest.setup_environment
      # w0t?
      super(*@options[:args])
    end

    def run(command)
      send(command)
    end

  end
end