Class: ClaudeMemory::Commands::PublishCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/claude_memory/commands/publish_command.rb

Overview

Publishes memory snapshot to Claude Code

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from ClaudeMemory::Commands::BaseCommand

Instance Method Details

#call(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/claude_memory/commands/publish_command.rb', line 7

def call(args)
  opts = parse_options(args, {mode: :shared, granularity: :repo, since: nil, scope: "project"}) do |o|
    OptionParser.new do |parser|
      parser.on("--mode MODE", "Mode: shared, local, or home") { |v| o[:mode] = v.to_sym }
      parser.on("--granularity LEVEL", "Granularity: repo, paths, or nested") { |v| o[:granularity] = v.to_sym }
      parser.on("--since ISO", "Include changes since timestamp") { |v| o[:since] = v }
      parser.on("--scope SCOPE", "Scope: project or global") { |v| o[:scope] = v }
    end
  end
  return 1 if opts.nil?

  manager = ClaudeMemory::Store::StoreManager.new
  store = manager.store_for_scope(opts[:scope])
  publish = ClaudeMemory::Publish.new(store)

  result = publish.publish!(mode: opts[:mode], granularity: opts[:granularity], since: opts[:since])

  case result[:status]
  when :updated
    stdout.puts "Published #{opts[:scope]} snapshot to #{result[:path]}"
  when :unchanged
    stdout.puts "No changes - #{result[:path]} is up to date"
  end

  manager.close
  0
end