Class: Dry::CLI::Autocomplete::Emitters::Zsh
- Inherits:
-
Object
- Object
- Dry::CLI::Autocomplete::Emitters::Zsh
- Defined in:
- lib/dry/cli/autocomplete/emitters/zsh.rb
Overview
Turns a CompletionSpec into a native zsh #compdef script.
This is not a bashcompinit shim. Options go through _arguments
carrying their desc as help text, subcommands go through
_describe, declared enum values become a (a b c) action, and a
file argument becomes _files. That per-option help is the thing
zsh users lose with a shim, and the reason this emitter exists.
See SPECIFICATION.md ยง4.1.
Shares no code with the bash emitter by design: a fourth shell should be a new class here, never another branch inside one of these two.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(spec) ⇒ Zsh
constructor
A new instance of Zsh.
Constructor Details
#initialize(spec) ⇒ Zsh
Returns a new instance of Zsh.
26 27 28 |
# File 'lib/dry/cli/autocomplete/emitters/zsh.rb', line 26 def initialize(spec) @spec = spec end |
Class Method Details
.call(spec) ⇒ Object
22 23 24 |
# File 'lib/dry/cli/autocomplete/emitters/zsh.rb', line 22 def self.call(spec) new(spec).call end |
Instance Method Details
#call ⇒ Object
30 31 32 |
# File 'lib/dry/cli/autocomplete/emitters/zsh.rb', line 30 def call "#{body.join("\n")}\n" end |