Class: Llmemory::Cli::Commands::LongTerm::Graph
- Defined in:
- lib/llmemory/cli/commands/long_term/graph.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#execute(argv, _opts) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/llmemory/cli/commands/long_term/graph.rb', line 16 def execute(argv, _opts) user_id = argv.first unless user_id $stderr.puts "Usage: llmemory graph USER_ID [--format dot|json]" exit 1 end storage = graph_based_storage(@store_type) nodes = storage.list_nodes(user_id) edges = storage.list_edges(user_id) case @format when "json" puts JSON.pretty_generate( nodes: nodes.map { |n| node_to_h(n) }, edges: edges.map { |e| edge_to_h(e) } ) else puts to_dot(nodes, edges) end end |
#option_parser(parser) ⇒ Object
11 12 13 14 |
# File 'lib/llmemory/cli/commands/long_term/graph.rb', line 11 def option_parser(parser) parser.on("--format FORMAT", "Output format: dot, json") { |v| @format = (v || "dot").downcase } parser.on("--store TYPE", "Storage type") { |v| @store_type = v } end |