Class: CLAideCompletion::Generator::Zsh

Inherits:
Object
  • Object
show all
Defined in:
lib/claide_completion/generator/zsh.rb

Overview

Generates a completion script for the Z shell.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Zsh

Returns a new instance of Zsh.

Parameters:

  • command (Class)

    The command to generate the script for.



11
12
13
# File 'lib/claide_completion/generator/zsh.rb', line 11

def initialize(command)
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/claide_completion/generator/zsh.rb', line 6

def command
  @command
end

Instance Method Details

#generateString

Returns The completion script.

Returns:

  • (String)

    The completion script.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/claide_completion/generator/zsh.rb', line 17

def generate
  result = "#compdef \#{command.command}\n# setopt XTRACE VERBOSE\n# vim: ft=zsh sw=2 ts=2 et\n\nlocal -a _subcommands\nlocal -a _options\n\n\#{case_statement_fragment(command)}\n"

  post_process(result)
end