Class: Ace::Assign::CLI::Commands::Status

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

Overview

Display current queue status.

Constant Summary collapse

STATUS_ICONS =
{
  done: "✓ Done",
  in_progress: "▶ Active",
  pending: "○ Pending",
  failed: "✗ Failed"
}.freeze
STATE_LABELS =
{
  running: "running",
  paused: "paused",
  completed: "completed",
  failed: "failed",
  empty: "empty",
  stalled: "stalled"
}.freeze
PROGRESS_BAR_WIDTH =
10
COL_NUMBER =
12
COL_STATUS =
12
COL_NAME =
30
COL_FORK =
6
PREVIEW_LIMIT =
5

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object

Raises:

  • (Ace::Support::Cli::Error)


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

def call(**options)
  target = resolve_assignment_target(options)
  view = resolve_assignment_view(target)

  return if options[:quiet]

  if options[:format] == "json"
    scoped_fork_step = (view.state, view.current_step, target.scope, view.scope_root)
    puts JSON.pretty_generate(
      status_to_h(view.assignment, view.scoped_state, view.current_step, scoped_fork_step: scoped_fork_step)
    )
    return
  end

  mode = normalize_mode(options[:mode])
  raise Ace::Support::Cli::Error, "--flat is supported only with --mode full" if options[:flat] && mode != "full"
  raise Ace::Support::Cli::Error, "--all is supported only with --mode full or compact" if options[:all] && mode == "progress"

  case mode
  when "progress"
    puts progress_summary_line(view.assignment, view.scoped_state, view.current_step)
  when "full"
    print_full_status(view, target, flat: options[:flat], include_completed: options[:all])
  else
    print_compact_status(view, target, include_completed: options[:all])
  end
end