Class: Bundlegem::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bundlegem/cli.rb

Defined Under Namespace

Classes: Gem

Constant Summary collapse

AUTO_INSTALL_CMDS =
%w[show binstubs outdated exec open console licenses clean]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bundlegem/cli.rb', line 19

def initialize(*args)
  super
  current_cmd = args.last[:current_command].name
  # custom_gemfile = options[:gemfile] || Bundlegem.settings[:gemfile]
  # ENV['BUNDLE_GEMFILE']   = File.expand_path(custom_gemfile) if custom_gemfile
  # Bundlegem::Retry.attempts = options[:retry] || Bundlegem.settings[:retry] || Bundlegem::Retry::DEFAULT_ATTEMPTS
  # Bundlegem.rubygems.ui = UI::RGProxy.new(Bundlegem.ui)
  # auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
rescue UnknownArgumentError => e
  raise InvalidOption, e.message
ensure
  self.options ||= {}
  # Bundlegem.ui = UI::Shell.new(options)
  # Bundlegem.ui.level = "debug" if options["verbose"]
end

Class Method Details

.handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/bundlegem/cli.rb', line 74

def self.handle_no_command_error(command, has_namespace = $thor_runner)
  require 'bundlegem/cli/gem'
  Gem.new(options, name, self).run



  # return super unless command_path = Bundlegem.which("Bundlegem-#{command}")

  # Kernel.exec(command_path, *ARGV[1..-1])
end

.source_rootObject



125
126
127
# File 'lib/bundlegem/cli.rb', line 125

def self.source_root
  File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

.startObject



9
10
11
12
13
14
15
16
17
# File 'lib/bundlegem/cli.rb', line 9

def self.start(*)
  super
rescue Exception => e
  # Bundlegem.ui = UI::Shell.new
  puts e
  raise e
ensure
  # Bundlegem.cleanup
end

Instance Method Details

#envObject



140
141
142
# File 'lib/bundlegem/cli.rb', line 140

def env
  Env.new.write($stdout)
end

#gem(name) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/bundlegem/cli.rb', line 117

def gem(name)
  # options = {"bin"=>false, "ext"=>false}
  # name = "gem_name"
  # self.class == Bundlegem::CLI
  require 'bundlegem/cli/gem'
  Gem.new(options, name, self).run
end

#help(cli = nil) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bundlegem/cli.rb', line 44

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
      bundle-platform
      gemfile.5)

  if manpages.include?(command)
    root = File.expand_path("../man", __FILE__)

    if Bundlegem.which("man") && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
      Kernel.exec "man #{root}/#{command}"
    else
      puts File.read("#{root}/#{command}.txt")
    end
  else
    super
  end
end

#initObject



92
93
94
95
# File 'lib/bundlegem/cli.rb', line 92

def init
  require 'bundlegem/cli/init'
  Init.new(options.dup).run
end

#platformObject



133
134
135
136
# File 'lib/bundlegem/cli.rb', line 133

def platform
  require 'bundlegem/cli/platform'
  Platform.new(options).run
end

#versionObject



100
101
102
# File 'lib/bundlegem/cli.rb', line 100

def version
  Bundler.ui.info "Bundler version #{Bundler::VERSION}"
end