Class: GradesFirst::TaskDeleteCommand

Inherits:
TaskCommand show all
Defined in:
lib/gradesfirst/task_delete_command.rb

Overview

Implementation of a Thor command for deleting tasks from PivotalTracker stories.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject

Description of the “gf task delete” Thor command that will be used in the commandline help.



10
11
12
# File 'lib/gradesfirst/task_delete_command.rb', line 10

def self.description
  'Delete a task from a PivotalTracker story.'
end

Instance Method Details

#execute(position) ⇒ Object

Performs the gf task delete POSITION Thor command.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gradesfirst/task_delete_command.rb', line 15

def execute(position)
  @story = current_story
  if @story
    task_id = get_task_id_by_position(@story, position)
    if task_id
      @success = task_delete(@story, task_id)
    else
      @task_position_invalid = true
    end
  end
end

#responseObject

Generates the command line output response. The output of the task delete command is a completion status message which may be followed by the new list of tasks if the task was deleted successfully.



30
31
32
33
34
35
36
# File 'lib/gradesfirst/task_delete_command.rb', line 30

def response
  if @task_position_invalid
    position_invalid_message
  else
    task_action_response(@story, @success)
  end
end