Skip to content

Commit

Permalink
pik install multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
vertiginous committed Jan 28, 2011
1 parent 69241b0 commit 0dd4014
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions lib/pik/commands/install_command.rb
Expand Up @@ -13,7 +13,11 @@ def install_root
end

def execute
name = @args.shift
list = config.options.fetch(:versions, @args.shift)
list.split(',').each{|name| install(name) }
end

def install(name)
ruby = Rubies[name]
abort "#{name} not found" unless ruby

Expand All @@ -22,13 +26,12 @@ def execute
Log.info("Installing #{ruby[:name]}")

@target = install_root + ruby[:name]
handle_target if @target.exist?

file = download(ruby[:url],ruby)

extract(@target, file)

add(@target)
if target_allowed?
file = download(ruby[:url],ruby)
extract(@target, file)
add(@target)
end
end

def command_options
Expand Down Expand Up @@ -57,15 +60,21 @@ def command_options
end
end

def handle_target
if @force
Log.info "Removing #{@target}"
FileUtils.rm_rf @target
def target_allowed?
if @target.exist?
if @force
Log.info "Removing #{@target}"
FileUtils.rm_rf @target
true
else
msg = "The directory '#{@target}' already exists.\n\n"
msg << "Run:\n\n 'pik install --force [ruby]'\n\n"
msg << "if you want to replace it.\n"
Log.error msg
false
end
else
msg = "\nThe directory '#{@target}' already exists.\n"
msg << "Run:\n\n 'pik install --force [ruby]'\n\n"
msg << "if you want to replace it.\n"
abort msg
true
end
end

Expand Down

0 comments on commit 0dd4014

Please sign in to comment.