Class: Dry::CLI::Completion::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/cli/completion/input.rb

Instance Method Summary collapse

Constructor Details

#initialize(registry, program_name) ⇒ Input

Returns a new instance of Input.



7
8
9
10
# File 'lib/dry/cli/completion/input.rb', line 7

def initialize(registry, program_name)
  @registry = registry
  @program_name = program_name
end

Instance Method Details

#call(include_aliases:) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/dry/cli/completion/input.rb', line 12

def call(include_aliases:)
  commands = extract_commands(root_node, include_aliases: include_aliases)
  commands.each_with_object({
    @program_name => commands.keys.map(&:first).uniq + ["help"]
  }) do |(name, config), input|
    input_line(input, "#{@program_name} #{name.join(" ")}", config[:arguments].shift, config)
  end
end