Class: Agent::Lock::CLI::Commands::Break

Inherits:
Base
  • Object
show all
Defined in:
lib/agent/lock/cli/commands/break.rb

Overview

Take a lock away from whoever holds it.

Deliberately blunt and deliberately loud: an expired lock is reaped on its own, so reaching for this means overruling a holder that still looks alive. Whoever runs it owns the consequence.

Instance Attribute Summary

Attributes inherited from Base

#launcher

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize

Constructor Details

This class inherits a constructor from Agent::Lock::CLI::Commands::Base

Instance Method Details

#call(scope:, **options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/agent/lock/cli/commands/break.rb', line 19

def call(scope:, **options)
  result = manager(options[:dir]).break_lock(scope)

  if result.status == :not_found
    say("NOT LOCKED #{scope}")
  else
    warn_("BREAKING #{result.record.scope}, held by #{result.record.agent_id}")
    warn_("  intent: #{result.record.intent}") unless result.record.intent.empty?
    say("Broken. You are responsible for having announced this first.")
  end

  finish(result)
end