Class: Ace::Assign::CLI::Commands::Finish

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

Overview

Complete in-progress step with report content

Instance Method Summary collapse

Instance Method Details

#call(step: nil, **options) ⇒ Object



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
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ace/assign/cli/commands/finish.rb', line 20

def call(step: nil, **options)
  if step && options[:assignment]
    raise Error, "Positional STEP targeting is only supported for active assignment. Use --assignment without STEP for cross-assignment finish."
  end

  target = resolve_assignment_target(options)
  executor = build_executor_for_target(target)
  report_content = resolve_report_content(options)
  result = executor.finish_step(
    report_content: report_content,
    step_number: step,
    fork_root: target.scope
  )

  return if options[:quiet]

  completed = result[:completed]
  puts "Step #{completed.number} (#{completed.name}) completed"

  assignment = result[:assignment]
  report_filename = Atoms::StepFileParser.generate_report_filename(completed.number, completed.name)
  report_path = File.join(assignment.reports_dir, report_filename)
  puts "Report saved to: #{report_path}"

  if result[:current]
    puts "Advancing to step #{result[:current].number}: #{result[:current].name}"
    puts "Next: ace-assign step#{step_target_suffix(result[:current].number, options[:assignment])}"
  else
    fork_root = target.scope&.strip
    if fork_root && result[:state].subtree_complete?(fork_root)
      puts "Fork subtree #{fork_root} completed."
    elsif result[:state].complete?
      puts "Assignment completed! All steps done."
    else
      puts "No active step selected."
    end
  end
end