Class: TempestTime::Commands::Teams::Edit
- Inherits:
-
TempestTime::Command
- Object
- TempestTime::Command
- TempestTime::Commands::Teams::Edit
- Defined in:
- lib/tempest_time/commands/teams/edit.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Edit
constructor
A new instance of Edit.
Methods inherited from TempestTime::Command
#command, #pastel, #prompt, #spinner, #table, #with_spinner, #with_success_fail_spinner
Constructor Details
#initialize(options) ⇒ Edit
Returns a new instance of Edit.
10 11 12 |
# File 'lib/tempest_time/commands/teams/edit.rb', line 10 def initialize() @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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tempest_time/commands/teams/edit.rb', line 14 def execute(input: $stdin, output: $stdout) teams = TempestTime::Settings::Teams abort("There are no teams to edit!") unless teams.keys.any? team = prompt.select( "Which #{pastel.green('team')} would you like to edit?", teams.keys ) members = teams.members(team) member = prompt.select( "Which #{pastel.green('member')} would you like to edit?", members + ['Add New Member'] ) replace = prompt.ask( "Enter the #{pastel.green('new name')}. "\ "Leave blank to #{pastel.red('delete')}." ) members.delete(member) if replace.nil? teams.update(team, members) prompt.say("Deleted #{pastel.red(member)}!") else members.push(replace) teams.update(team, members) prompt.say("Added #{pastel.green(replace)}") end execute if prompt.yes?('Keep editing?') end |