Class: Textus::Surfaces::CLI::Verb::Get

Inherits:
Runner::Base show all
Defined in:
lib/textus/surfaces/cli/verb/get.rb

Instance Attribute Summary

Attributes inherited from Textus::Surfaces::CLI::Verb

#positional, #stdin

Instance Method Summary collapse

Methods inherited from Runner::Base

#call, command_name, #flag_values, #spec

Methods inherited from Textus::Surfaces::CLI::Verb

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

Constructor Details

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

Instance Method Details

#invoke(store) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
# File 'lib/textus/surfaces/cli/verb/get.rb', line 9

def invoke(store)
  key = positional.shift or raise UsageError.new("get requires a key")
  cmd = Textus::Command::Get.new(key: key, role: resolved_role(store))
  result = store.gate.dispatch(cmd)
  raise Textus::UnknownKey.new(key, suggestions: store.manifest.resolver.suggestions_for(key)) if result.nil?

  emit(result.to_h_for_wire)
end