Class: EPC::Command::DeleteProjectCommand

Inherits:
BaseCommand show all
Defined in:
lib/epc/command/delete_project_command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS

Instance Attribute Summary

Attributes inherited from BaseCommand

#client, #options

Instance Method Summary collapse

Methods inherited from BaseCommand

#go, inherited, #initialize, #method_missing, required_arguments_count, required_options, #respond_to?

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

This class inherits a constructor from EPC::Command::BaseCommand

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EPC::Command::BaseCommand

Instance Method Details

#execute(project_name = nil) ⇒ Object



3
4
5
6
7
8
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
35
36
37
38
39
40
41
# File 'lib/epc/command/delete_project_command.rb', line 3

def execute(project_name = nil)
  path = "."
  path = File.expand_path(path)

  solution_name = @options[:solution_name]

  solution_id, solution_name = infer_solution_context(solution_name, path, :get_solution_name => true)
  project_id, project_name = infer_project_context(project_name, path, solution_id, {:get_project_name => true})

  if project_id.nil?
    say("Project name could not be inferred")
    say(EPC::Help::COMMAND_USAGES[:delete_project])
    return 1
  end

  question = "You are deleting the project [#{project_id}"
  if project_name.nil?
    question += "] Correct? [Yn] "
  else
    question += " - #{project_name}].Correct? [Yn] " 
  end

  unless @options[:force]
    proceed = ask_yn(question)
    if proceed.upcase == 'N'
      return 1
    end
  end

  status, response, message = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}")
  if status.successful?
    (path, project_name) if EPC::Config.is_project_dir?(path) || EPC::Config.is_solution_dir?(path)
    say("Project deleted.")
  else
    say("Project could not be deleted. Delete failed with: [#{response[:message]}]")
  end
  return status

end