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

Inherits:
Textus::CLI::Verb show all
Defined in:
lib/textus/cli/verb/get.rb

Instance Attribute Summary

Attributes inherited from Textus::CLI::Verb

#positional

Instance Method Summary collapse

Methods inherited from Textus::CLI::Verb

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

Constructor Details

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

Instance Method Details

#call(store) ⇒ Object

Raises:



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

def call(store)
  key = positional.shift or raise UsageError.new("get requires a key")
  result = operations_for(store).get_or_refresh(key)
  raise Textus::UnknownKey.new(key, suggestions: store.manifest.resolver.suggestions_for(key)) if result.nil?

  emit(result.to_h_for_wire)
end