Class: MicroManager::CLI::CompleteTask

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/complete_task.rb

Instance Method Summary collapse

Constructor Details

#initialize(prompt: TTY::Prompt.new) ⇒ CompleteTask

Returns a new instance of CompleteTask.



8
9
10
# File 'lib/cli/complete_task.rb', line 8

def initialize(prompt: TTY::Prompt.new)
  @prompt = prompt
end

Instance Method Details

#run(schedule:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cli/complete_task.rb', line 12

def run(schedule:)
  tasks = schedule.outstanding_tasks
  options = tasks.map { |task| { task.description => task } }
  options << { "Exit" => nil }

  Result.new do
    task = prompt.select("Complete task", options)
    task&.complete

    nil
  end
end