Class: RubynCode::CLI::Commands::Tasks

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/tasks.rb

Constant Summary collapse

STATUS_COLORS =
{
  'completed' => :green,
  'in_progress' => :yellow,
  'blocked' => :red
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases, all_names, hidden?

Class Method Details

.command_nameObject



7
# File 'lib/rubyn_code/cli/commands/tasks.rb', line 7

def self.command_name = '/tasks'

.descriptionObject



8
# File 'lib/rubyn_code/cli/commands/tasks.rb', line 8

def self.description = 'List all tasks'

Instance Method Details

#execute(_args, ctx) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubyn_code/cli/commands/tasks.rb', line 16

def execute(_args, ctx)
  task_manager = ::RubynCode::Tasks::Manager.new(ctx.db)
  tasks = task_manager.list

  if tasks.empty?
    ctx.renderer.info('No tasks.')
    return
  end

  tasks.each do |t|
    puts "  [#{t[:status]}] #{t[:title]} (#{t[:id][0..7]})"
  end
end