Sha256: 4cfdfcbd2b36a1209a59b160be15213a828c6e1ea32b00dfadadecbbd4b25a05

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

require "autoproj/shell_completion"

module Autoproj
    # This class generates shell completion for code for a given Thor subclasss
    class ZshCompletion < ShellCompletion
        MAIN_FUNCTION_TEMPLATE = "main.zsh.erb"
        SUBCOMMAND_FUNCTION_TEMPLATE = "subcommand.zsh.erb"

        def setup_file_completion(metadata)
            metadata[:completer] = "_files"
        end

        def setup_executable_completion(metadata)
            metadata[:completer] = "_path_commands"
        end

        def setup_package_completion(metadata)
            metadata[:completer] = "_autoproj_installed_packages"
        end

        def disable_completion(metadata)
            metadata[:completer] = ":"
        end

        def quote(s)
            escaped = s.gsub(/'/, "''")
            %('#{escaped}')
        end

        def bracket(s)
            %([#{s}])
        end

        def escape_option_names(names)
            if names.size == 1
                names.first
            else
                "{#{names.join(',')}}"
            end
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
autoproj-2.17.0 lib/autoproj/zsh_completion.rb
autoproj-2.16.0 lib/autoproj/zsh_completion.rb
autoproj-2.15.3 lib/autoproj/zsh_completion.rb
autoproj-2.15.2 lib/autoproj/zsh_completion.rb
autoproj-2.15.1 lib/autoproj/zsh_completion.rb
autoproj-2.15.0 lib/autoproj/zsh_completion.rb