Class: Ace::Assign::CLI::Commands::List

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/assign/cli/commands/list.rb

Overview

List all assignments with state information

Examples:

List active assignments

ace-assign list

Include completed assignments

ace-assign list --all

Filter by task

ace-assign list --task my-task

JSON output

ace-assign list --format json

Constant Summary collapse

COL_ID =

Column widths for table display

10
COL_NAME =
25
COL_STATUS =
12
COL_PROGRESS =
10
COL_STEP =
20
COL_UPDATED =
15
STATE_LABELS =

Status display labels

{
  running: "running",
  paused: "paused",
  completed: "completed",
  failed: "failed",
  empty: "empty"
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ace/assign/cli/commands/list.rb', line 51

def call(**options)
  discoverer = Molecules::AssignmentDiscoverer.new
  manager = Molecules::AssignmentManager.new
  current_id = manager.current_id

  all_assignments = discoverer.find_all(include_completed: true)
  assignments = if options[:task]
    all_assignments.select { |ai| ai.assignment.name == options[:task] }
      .then { |filtered| options[:all] ? filtered : filtered.reject(&:completed?) }
  elsif options[:all]
    all_assignments
  else
    all_assignments.reject(&:completed?)
  end

  hidden_completed = options[:all] ? 0 : all_assignments.count(&:completed?)

  if options[:tree]
    print_tree(assignments)
  elsif options[:format] == "json"
    print_json(assignments, current_id: current_id)
  else
    print_table(assignments, current_id: current_id, hidden_completed: hidden_completed)
  end
end