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

Inherits:
TreeCommand
  • 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 TreeCommand

inherited

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#call(scope:, text:, **options) ⇒ Manager::Result

Returns :noted, :not_found or :refused.

Parameters:

  • scope (String)
  • text (String)
  • options (Hash) —

    :dir, :locking_strategy, :redis_url

Returns:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/agent/lock/cli/commands/note.rb', line 26

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

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

  finish(result)
end