Module: CLAideCompletion::Generator
- Defined in:
- lib/claide_completion/generator.rb,
lib/claide_completion/generator/zsh.rb
Defined Under Namespace
Classes: ShellCompletionNotFound, Zsh
Class Method Summary collapse
- .generate(command, shell = nil) ⇒ Object
-
.indent(string, indentation) ⇒ String
Indents the lines of the given string except the first one to the given level.
Class Method Details
.generate(command, shell = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/claide_completion/generator.rb', line 9 def self.generate(command, shell = nil) shell ||= ENV['SHELL'].split(File::SEPARATOR).last begin generator = const_get(shell.capitalize.to_sym) rescue NameError raise ShellCompletionNotFound, 'Auto-completion generator for ' \ "the `#{shell}` shell is not implemented." end generator.new(command).generate end |
.indent(string, indentation) ⇒ String
Indents the lines of the given string except the first one to the given level. Uses two spaces per each level.
31 32 33 |
# File 'lib/claide_completion/generator.rb', line 31 def indent(string, indentation) string.gsub("\n", "\n#{' ' * indentation * 2}") end |