Class: TempestTime::Commands::Teams::Delete

Inherits:
TempestTime::Command show all
Defined in:
lib/tempest_time/commands/teams/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(options) ⇒ Delete

Returns a new instance of Delete.



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

def initialize(options)
  @options = options
end

Instance Method Details

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



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tempest_time/commands/teams/delete.rb', line 14

def execute(input: $stdin, output: $stdout)
  teams = TempestTime::Settings::Teams
  abort("There are no teams to delete!") unless teams.keys.any?
  team = prompt.select(
    "Which #{pastel.green('team')} would you like to delete?",
    teams.keys
  )
  if prompt.yes?(pastel.red("Are you sure you want to delete #{team}?"))
    teams.delete(team)
    prompt.say("Successfully #{pastel.red("deleted #{team}!")}")
  else
    abort('Nothing was deleted.')
  end
  execute if prompt.yes?('Delete another team?')
end