Class: Textus::Surface::CLI::Verb::Put

Inherits:
Runner::Base show all
Defined in:
lib/textus/surface/cli/verb/put.rb

Instance Attribute Summary

Attributes inherited from Textus::Surface::CLI::Verb

#positional, #stdin

Instance Method Summary collapse

Methods inherited from Runner::Base

#call, command_name, #flag_values, #spec

Methods inherited from Textus::Surface::CLI::Verb

command_name, descendants, #emit, inherited, #initialize, needs_store?, option, options, parent_group, #parse, #resolved_role

Constructor Details

This class inherits a constructor from Textus::Surface::CLI::Verb

Instance Method Details

#invoke(store) ⇒ Object

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/textus/surface/cli/verb/put.rb', line 11

def invoke(store)
  key = positional.shift or raise UsageError.new("put requires a key")
  raise UsageError.new("put requires --stdin in v1") unless use_stdin

  payload = JSON.parse(@stdin.read)
  Textus::Protocol::VerbRegistry.for(:put)
  inputs = { key: key, meta: payload["_meta"] || {}, data: payload["data"],
             if_etag: payload["if_etag"] }
  inputs[:format] = as_format if as_format
  s = store.with_role(resolved_role(store))
  emit(s.put(**inputs))
end