Class: Cerberus::RemoveCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/cerberus/manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(application_name, cli_options = {}) ⇒ RemoveCommand

DRY: this is ugly and needs refactoring. It duplicates functionality from other classes a lot.



56
57
58
59
60
61
62
63
64
# File 'lib/cerberus/manager.rb', line 56

def initialize(application_name, cli_options = {})
  unless File.exists?("#{HOME}/config/#{application_name}.yml")
    say "Project '#{application_name}' does not exist in Cerberus. Type 'cerberus list' to see the list of all active projects."
  end
  @app_root = "#{HOME}/work/#{application_name}"
  
  def_options = {:application_root => @app_root, :application_name => application_name}
  @config = Config.new(application_name, cli_options.merge(def_options))
end

Instance Method Details

#runObject



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cerberus/manager.rb', line 66

def run
  application_name = @config[:application_name]
  
  config_name = "#{HOME}/config/#{application_name}.yml"
  
  if not File.exists?(config_name)
    say "Unknown application #{application_name}"
    exit(1) 
  end
  FileUtils.rm_rf @config[:application_root]
  File.unlink config_name
  puts "Application '#{application_name}' removed." unless @config[:quiet]
end