Class: Pik::UnInstall

Inherits:
Command show all
Defined in:
lib/pik/commands/uninstall_command.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#config, #debug, #options, #output, #version

Instance Method Summary collapse

Methods inherited from Command

#actual_gem_home, #add_sigint_handler, aka, choose_from, clean_gem_batch, #close, cmd_name, #cmd_name, #create, #current_gem_bin_path, #current_version?, #default_gem_home, #delete_old_pik_batches, description, #editors, #find_config_from_path, #get_gem_home, #get_version, hl, inherited, #initialize, it, names, #parse_options, #pik_version, #sh, summary

Constructor Details

This class inherits a constructor from Pik::Command

Instance Attribute Details

#forceObject (readonly)

Returns the value of attribute force.



9
10
11
# File 'lib/pik/commands/uninstall_command.rb', line 9

def force
  @force
end

Instance Method Details

#command_optionsObject



30
31
32
33
34
35
# File 'lib/pik/commands/uninstall_command.rb', line 30

def command_options
  super
  options.on("--force", "-f", "Remove without prompting") do |value|
    @force = value
  end
end

#executeObject

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pik/commands/uninstall_command.rb', line 11

def execute
  to_remove = self.class.choose_from(@args, @config)
  raise QuitError unless to_remove
  if force || @hl.agree("Are you sure you'd like to uninstall '#{to_remove}'?"){|answer| answer.default = 'yes' }
    puts "** Deleting #{config[to_remove][:path].dirname}"
    path = config[to_remove][:path].dirname
    FileUtils.rm_rf(path) if path.exist?
    remove
    puts
    @hl.say("#{to_remove} has been uninstalled.")
  end
end

#removeObject



24
25
26
27
28
# File 'lib/pik/commands/uninstall_command.rb', line 24

def remove
  rm = Pik::Remove.new(@args + ['--force', '--quiet'], config)
  rm.execute
  rm.close
end