Class: Agent::Lock::CLI::Commands::Note

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

Overview

Write down where you are, in the lock itself.

The lock and the notes have one lifespan on purpose. A machine that reboots loses the session but not the file, so the next run reads one document and knows what was underway and how far it got.

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:, text:, **options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/agent/lock/cli/commands/note.rb', line 22

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

  case result.status
  when :noted then say("NOTED #{result.record.scope}")
  when :not_found then warn_("NOT LOCKED #{scope}, take the lock before writing in it")
  when :refused then warn_("REFUSED: #{result.record.scope} is held by #{result.record.agent_id}")
  end

  finish(result)
end