Class: TempestTime::Commands::Delete

Inherits:
TempestTime::Command show all
Defined in:
lib/tempest_time/commands/delete.rb

Instance Method Summary collapse

Methods inherited from TempestTime::Command

#command, #pastel, #prompt, #spinner, #table, #with_spinner, #with_success_fail_spinner

Constructor Details

#initialize(worklogs, options) ⇒ Delete

Returns a new instance of Delete.



9
10
11
12
# File 'lib/tempest_time/commands/delete.rb', line 9

def initialize(worklogs, options)
  @worklogs = worklogs
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/tempest_time/commands/delete.rb', line 14

def execute(input: $stdin, output: $stdout)
  pluralized = @worklogs.length > 1 ? 'worklogs' : 'worklog'
  confirm_message =
    "Delete #{pluralized} #{pastel.green(@worklogs.join(', '))}?"
  abort unless prompt.yes?(confirm_message)
  @worklogs.each { |worklog| delete_worklog(worklog) }
end