Sha256: 070d8ab2cf6eb04704419c0049012222044cd274fb02171a22f87753fd5dee8d

Contents?: true

Size: 1.99 KB

Versions: 306

Compression:

Stored size: 1.99 KB

Contents

function _inspec() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

    local -a _top_level_commands <%= subcommands_with_commands_and_descriptions.keys.map {|i| "_#{i}_commands" }.join(' ') %>

    _top_level_commands=(
<%= top_level_commands_with_descriptions.map {|i| " "*8 + "\"#{i}\"" }. join("\n") %>
    )

<% subcommands_with_commands_and_descriptions.each do |name, entry| -%>
    _<%= name %>_commands=(
<%= entry.map {|i| " "*8 + "\"#{i}\"" }.join("\n") %>
    )

<% end -%>
    _arguments '1:::->toplevel' && return 0
    _arguments '2:::->subcommand' && return 0
    _arguments '3:::->subsubcommand' && return 0

    #
    # Are you thinking? "Jeez, whoever wrote this really doesn't get
    # zsh's completion system?" If so, you are correct. However, I
    # have goodnews! Pull requests are accepted!
    #
    case $state in
        toplevel)
            _describe -t commands "InSpec subcommands" _top_level_commands
            ;;
        subcommand)
            case "$words[2]" in
                archive|check|exec|json)
                    _alternative 'files:filenames:_files'
                    ;;
                help)
                    _describe -t commands "InSpec subcommands" _top_level_commands
                    ;;
<% subcommands_with_commands_and_descriptions.each do |name, entry| -%>
                <%= name %>)
                    _describe -t <%= name %>_commands "InSpec <%= name -%> subcommands" _<%= name %>_commands
                    ;;
<% end -%>
            esac
            ;;
        subsubcommand)
            case "$words[2]-$words[3]" in
                compliance-upload)
                    _alternative 'files:filenames:_files'
                    ;;
<% subcommands_with_commands_and_descriptions.each do |name, entry| -%>
                <%= name %>-help)
                    _describe -t <%= name %>_commands "InSpec <%= name %> subcommands" _<%= name %>_commands
                    ;;
<% end -%>
            esac

    esac

}

compdef _inspec inspec

Version data entries

306 entries across 306 versions & 2 rubygems

Version Path
inspec-core-6.8.24 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.65 lib/inspec/completions/zsh.sh.erb
inspec-core-6.8.11 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.58 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.55 lib/inspec/completions/zsh.sh.erb
inspec-core-6.8.1 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.40 lib/inspec/completions/zsh.sh.erb
inspec-core-6.6.0 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.36 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.29 lib/inspec/completions/zsh.sh.erb
inspec-core-4.56.58 lib/inspec/completions/zsh.sh.erb
inspec-core-5.22.3 lib/inspec/completions/zsh.sh.erb
inspec-core-5.21.29 lib/inspec/completions/zsh.sh.erb
inspec-core-5.18.14 lib/inspec/completions/zsh.sh.erb
inspec-core-5.17.4 lib/inspec/completions/zsh.sh.erb
inspec-core-5.14.0 lib/inspec/completions/zsh.sh.erb
inspec-core-4.56.20 lib/inspec/completions/zsh.sh.erb
inspec-core-5.12.2 lib/inspec/completions/zsh.sh.erb
inspec-core-5.10.5 lib/inspec/completions/zsh.sh.erb
inspec-core-4.56.19 lib/inspec/completions/zsh.sh.erb