Sha256: 2de1f9cfb53cd6c3d03b2ca5c756760051c1a86c8c80dce57f72f1569c350e3a
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
module CLAideCompletion module Generator class ShellCompletionNotFound < StandardError include CLAide::InformativeError end autoload :Zsh, 'claide_completion/generator/zsh' 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 # Indents the lines of the given string except the first one to the given # level. Uses two spaces per each level. # # @param [String] string # The string to indent. # # @param [Fixnum] indentation # The indentation amount. # # @return [String] An indented string. # def indent(string, indentation) string.gsub("\n", "\n#{' ' * indentation * 2}") end module_function :indent end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
claide-completion-1.0.2 | lib/claide_completion/generator.rb |
claide-completion-1.0.1 | lib/claide_completion/generator.rb |
claide-completion-1.0.0 | lib/claide_completion/generator.rb |