Class: Ace::Git::Worktree::Commands::CleanupCommand
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Commands::CleanupCommand
- Defined in:
- lib/ace/git/worktree/commands/cleanup_command.rb
Overview
Cleanup command
Generates a complete, deterministic, report-only worktree cleanup inventory using ancestry as the first safe proof. No mutations are performed — this is strictly a report.
Instance Method Summary collapse
-
#run(args = []) ⇒ Integer
Run the cleanup command.
Instance Method Details
#run(args = []) ⇒ Integer
Run the cleanup command
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ace/git/worktree/commands/cleanup_command.rb', line 27 def run(args = []) = parse_arguments(args) return show_help if [:help] () result = build_reporter().report if result[:success] if [:apply] apply_result = apply_fresh_report() if apply_result[:success] # Strict rescan with the same selection final_result = build_reporter().report if final_result[:success] # Check require_only_target if needed if [:require_only_target] && has_non_target_state?(final_result) puts "Cleanup applied successfully, but non-target state remains (failed strict --require-only-target check)." display_result(final_result, ) return 1 end display_apply_result(apply_result, final_result, ) return 0 else puts "Cleanup applied successfully, but final strict rescan failed: #{final_result[:error]}" return 1 end else puts "Error applying cleanup: #{apply_result[:error]}" display_apply_result(apply_result, nil, ) return 1 end else display_result(result, ) return 0 end else if [:format] == "json" puts JSON.pretty_generate(result) else puts "Error: #{result[:error]}" end 1 end rescue ArgumentError => e puts "Error: #{e.}" puts show_help 1 rescue => e puts "Error: #{e.}" 1 end |