Class: UninstallCommand

Inherits:
Command show all
Includes:
Rcli::Installation
Defined in:
lib/commands/uninstall.rb

Instance Attribute Summary

Attributes inherited from Command

#description

Instance Method Summary collapse

Methods included from Rcli::Installation

#_installed_rcli_base?

Methods inherited from Command

#after_init, #before_init, default_cmd, describe, description, get_allowed_commands, #help, #initialize, load, load_all, #run, show_use, usage

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#mainObject



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
# File 'lib/commands/uninstall.rb', line 9

def main()
  
  if $verbose
    print "params : "
    pp @params
  end
    
  if _installed_rcli_base? && @params[:args].length > 0
    unless !File.exists? Rcli::RCLI_DOTFOLDER + DS + 'bin' + DS + @params[:args][0]
      puts "ERROR: The rcli app you provided does not exist. Please type 'rcli list' for list of installed apps."
    end

    FileUtils.rm(File.exists? Rcli::RCLI_DOTFOLDER + DS + 'bin' + DS + @params[:args][0])
    FileUtils.rm(File.exists? Rcli::RCLI_DOTFOLDER + DS + 'app_info' + DS + @params[:args][0] + '.yml')

  elsif @params[:args].length > 0 && !_installed_rcli_base?
    puts "You haven't installed the rcli base yet. Please run 'rcli install' first."
  elsif _installed_rcli_base?
    if agree('Are you sure you want to completely remove rcli from your system? (y/n)', true)
      puts "Deleting : " + Rcli::RCLI_DOTFOLDER if $verbose
      FileUtils.rm_rf(Rcli::RCLI_DOTFOLDER)
    end
  else
    puts "ERROR: rcli isn't installed"
  end
end