Class: Ocak::Commands::Clean

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/ocak/commands/clean.rb

Instance Method Summary collapse

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ocak/commands/clean.rb', line 11

def call(**)
  config = Config.load
  manager = WorktreeManager.new(config: config)

  puts 'Cleaning stale worktrees...'
  removed = manager.clean_stale

  if removed.empty?
    puts 'No stale worktrees found.'
  else
    removed.each { |path| puts "  Removed: #{path}" }
    puts "Cleaned #{removed.size} worktree(s)."
  end
rescue Config::ConfigNotFound => e
  warn "Error: #{e.message}"
  exit 1
end