Class: Lyman::CLI::Commands::Eject

Inherits:
Object
  • Object
show all
Defined in:
lib/lyman/cli/commands/eject.rb

Overview

lyman eject ARTIFACT — rewrites a managed artifact's manifest entry into a tombstone (status: ejected, ejected_at, pristine_hash), transferring ownership without deleting history. See docs/design/ deployment.md ("Eject-to-own"). The pristine copy is left in place — it becomes the fork point that makes a later lyman diff meaningful.

Instance Method Summary collapse

Constructor Details

#initialize(thor, source_root:) ⇒ Eject

Returns a new instance of Eject.



10
11
12
13
# File 'lib/lyman/cli/commands/eject.rb', line 10

def initialize(thor, source_root:)
  @thor = thor
  @source_root = source_root
end

Instance Method Details

#call(artifact) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lyman/cli/commands/eject.rb', line 15

def call(artifact)
  project_root = Manifest.find!
  manifest = Manifest.load(project_root)
  name = Registry.resolve(artifact, manifest: manifest)
  entry = manifest.artifact(name)

  case entry&.fetch("status", nil)
  when "managed"
    eject(manifest, name, entry)
  when "owned"
    @thor.say "#{name} is already yours; lyman never manages #{entry["path"]}."
  when "ejected"
    @thor.say "#{name} was already ejected at #{entry["ejected_at"]}; nothing to do."
  else
    raise Thor::Error, "#{name} isn't planted in this project; nothing to eject."
  end
end