Class: CLI::Kit::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/kit/resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(tool_name:, command_registry:) ⇒ Resolver

Returns a new instance of Resolver.



6
7
8
9
# File 'lib/cli/kit/resolver.rb', line 6

def initialize(tool_name:, command_registry:)
  @tool_name = tool_name
  @command_registry = command_registry
end

Instance Method Details

#call(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cli/kit/resolver.rb', line 11

def call(args)
  args = args.dup
  command_name = args.shift

  command, resolved_name = @command_registry.lookup_command(command_name)

  if command.nil?
    command_not_found(command_name)
    raise CLI::Kit::AbortSilent # Already output message
  end

  [command, resolved_name, args]
end