Class: Textus::CLI::Verb::Put
- Inherits:
-
Textus::CLI::Verb
- Object
- Textus::CLI::Verb
- Textus::CLI::Verb::Put
- Defined in:
- lib/textus/cli/verb/put.rb
Instance Attribute Summary
Attributes inherited from Textus::CLI::Verb
Instance Method Summary collapse
Methods inherited from Textus::CLI::Verb
command_name, #context_for, descendants, #emit, inherited, #initialize, needs_store?, option, options, parent_group, #parse, #resolved_role, #session_for
Constructor Details
This class inherits a constructor from Textus::CLI::Verb
Instance Method Details
#call(store) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/textus/cli/verb/put.rb', line 11 def call(store) key = positional.shift or raise UsageError.new("put requires a key") raise UsageError.new("put requires --stdin in v1") unless use_stdin role = resolved_role(store) raw = @stdin.read payload = if fetch_name result = Textus::Write::IntakeFetch.invoke( rpc: store.rpc, handler: fetch_name, config: { "bytes" => raw }, args: {}, label: "fetch" ) basename = key.split(".").last { "_meta" => { "name" => basename, "last_refreshed_at" => Time.now.utc.iso8601, "fetched_with" => fetch_name, }.merge(result[:_meta] || result["_meta"] || {}), "body" => result[:body] || result["body"] || "", } else JSON.parse(raw) end = payload["_meta"] || {} body = payload["body"] || "" if_etag = payload["if_etag"] result = store.as(role).put(key, meta: , body: body, if_etag: if_etag) emit(result.to_h_for_wire) end |