Class: Dry::CLI::Autocomplete::SpecBuilder
- Inherits:
-
Object
- Object
- Dry::CLI::Autocomplete::SpecBuilder
- Defined in:
- lib/dry/cli/autocomplete/spec_builder.rb
Overview
Walks a Dry::CLI registry through its public API and returns a shell-agnostic description of every completion: one CompletionSpec carrying one Node per reachable, non-hidden command or group.
Touches nothing beyond the registry and the command classes it already holds, so it stays cheap enough to run on every shell start. See SPECIFICATION.md §2.2 and §2.3.
Defined Under Namespace
Classes: ArgumentSpec, CompletionSpec, Node, OptionSpec
Constant Summary collapse
- FILE_ARGUMENT_HEURISTIC =
A bare heuristic, used only when a host does not declare
file:explicitly on the argument. See SPECIFICATION.md §4.3. /file|path/i
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(registry, program_name) ⇒ SpecBuilder
constructor
A new instance of SpecBuilder.
Constructor Details
#initialize(registry, program_name) ⇒ SpecBuilder
Returns a new instance of SpecBuilder.
41 42 43 44 |
# File 'lib/dry/cli/autocomplete/spec_builder.rb', line 41 def initialize(registry, program_name) @registry = registry @program_name = program_name end |
Class Method Details
.call(registry, program_name:) ⇒ Object
37 38 39 |
# File 'lib/dry/cli/autocomplete/spec_builder.rb', line 37 def self.call(registry, program_name:) new(registry, program_name).call end |
Instance Method Details
#call ⇒ Object
46 47 48 |
# File 'lib/dry/cli/autocomplete/spec_builder.rb', line 46 def call CompletionSpec.new(program_name: program_name, nodes: walk([])) end |