Class: Commands::Install

Inherits:
Object show all
Defined in:
lib/commands/extension.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_command) ⇒ Install

Returns a new instance of Install.



189
190
191
192
193
# File 'lib/commands/extension.rb', line 189

def initialize(base_command)
  @base_command = base_command
  @method = :http
  @options = { :quiet => false, :force => false }
end

Instance Method Details

#optionsObject



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/commands/extension.rb', line 195

def options
  OptionParser.new do |o|
    o.set_summary_indent('  ')
    o.banner =    "Usage: #{@base_command.script_name} install EXTENSION [EXTENSION [EXTENSION] ...]"
    o.define_head "Install one or more extensions."
    o.separator   ""
    o.separator   "Options:"
    o.on(         "-q", "--quiet",
                  "Suppresses the output from installation.",
                  "Ignored if -v is passed (./script/extension -v install ...)") { |v| @options[:quiet] = true }
    o.on(         "-f", "--force",
                  "Reinstalls an extension if it's already installed.") { |v| @options[:force] = true }
    o.separator   ""
    o.separator   "You must specify extensions as absolute URLs to a plugin repository."
  end
end

#parse!(args) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/commands/extension.rb', line 212

def parse!(args)
  options.parse!(args)
  environment = @base_command.environment
  install_method = :clone
  puts "Extensions will be installed using #{install_method}" if $verbose
  args.each do |name|
    ::Extension.new(name).install(@options)
  end
rescue StandardError => e
  puts "Extension not found: #{args.inspect}"
  puts e.inspect if $verbose
  exit 1
end