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

#context_for, #emit, inherited, #initialize, needs_store?, option, options, #parse, #resolved_role

Constructor Details

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

Instance Method Details

#call(store) ⇒ Object

Raises:



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

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

  emit(result)
end