#compdef pcorelist

# Generated with perl module App::Spec v0.000

_pcorelist() {
    local program=pcorelist
    typeset -A opt_args
    local curcontext="$curcontext" state line context


        # ---- Command: 
        _arguments -s  \
            '1: :->cmd1' \
            '*: :->args' \
            && ret=0


        case $state in
        cmd1)
            _alternative 'args:cmd2:((diff\:"Show diff between two Perl versions" features\:"List features with perl versions" help\:"Show command help" module\:"Show for which perl version the module was first released" modules\:"List all modules" perl\:"Perl Versions"))'
        ;;

        args)
            case $line[1] in
            _meta)

                # ---- Command: _meta
                _arguments -s -C \
                    '1: :->cmd1' \
                    '2: :->cmd2' \
                    '*: :->args' \
                    && ret=0


                case $state in
                cmd2)
                    _alternative 'args:cmd3:((completion\:"Shell completion functions" pod\:"Pod documentation"))'
                ;;

                args)
                    case $line[2] in
                    completion)

                        # ---- Command: _meta completion
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->cmd3' \
                            '*: :->args' \
                            && ret=0


                        case $state in
                        cmd3)
                            _alternative 'args:cmd4:((generate\:"Generate self completion"))'
                        ;;

                        args)
                            case $line[3] in
                            generate)

                                # ---- Command: _meta completion generate
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--name[name of the program (optional, override name in spec)]:name' \
                                    '--zsh[for zsh]' \
                                    '--bash[for bash]' \
                                    && ret=0


                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    pod)

                        # ---- Command: _meta pod
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->cmd3' \
                            '*: :->args' \
                            && ret=0


                        case $state in
                        cmd3)
                            _alternative 'args:cmd4:((generate\:"Generate self pod"))'
                        ;;

                        args)
                            case $line[3] in
                            generate)

                                # ---- Command: _meta pod generate
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    && ret=0


                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    esac

                ;;

                esac
            ;;
            diff)

                # ---- Command: diff
                _arguments -s -C \
                    '1: :->cmd1' \
                    '2: :->perl1' \
                    '3: :->perl2' \
                    '--help[Show command help]' \
                    '-h[Show command help]' \
                    '--added[Show only added modules]' \
                    '--removed[Show only removed modules]' \
                    && ret=0

                case $state in
                perl1)
_pcorelist_diff_param_perl1_completion
                ;;
                perl2)
_pcorelist_diff_param_perl2_completion
                ;;
                esac

            ;;
            features)

                # ---- Command: features
                _arguments -s -C \
                    '1: :->cmd1' \
                    '2: :->feature' \
                    '--help[Show command help]' \
                    '-h[Show command help]' \
                    '--raw[List only feature names]' \
                    && ret=0

                case $state in
                feature)
_pcorelist_features_param_feature_completion
                ;;
                esac

            ;;
            help)

                # ---- Command: help
                _arguments -s -C \
                    '1: :->cmd1' \
                    '2: :->cmd2' \
                    '*: :->args' \
                    && ret=0


                case $state in
                cmd2)
                    _alternative 'args:cmd3:((diff features module modules perl))'
                ;;

                args)
                    case $line[2] in
                    _meta)

                        # ---- Command: help _meta
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->cmd3' \
                            '*: :->args' \
                            && ret=0


                        case $state in
                        cmd3)
                            _alternative 'args:cmd4:((completion pod))'
                        ;;

                        args)
                            case $line[3] in
                            completion)

                                # ---- Command: help _meta completion
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '4: :->cmd4' \
                                    '*: :->args' \
                                    && ret=0


                                case $state in
                                cmd4)
                                    _alternative 'args:cmd5:((generate))'
                                ;;

                                args)
                                    case $line[4] in
                                    generate)

                                        # ---- Command: help _meta completion generate
                                        _arguments -s -C \
                                            '1: :->cmd1' \
                                            '2: :->cmd2' \
                                            '3: :->cmd3' \
                                            '4: :->cmd4' \
                                            '--help[Show command help]' \
                                            '-h[Show command help]' \
                                            '--all[]' \
                                            && ret=0


                                    ;;
                                    esac

                                ;;

                                esac
                            ;;
                            pod)

                                # ---- Command: help _meta pod
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '4: :->cmd4' \
                                    '*: :->args' \
                                    && ret=0


                                case $state in
                                cmd4)
                                    _alternative 'args:cmd5:((generate))'
                                ;;

                                args)
                                    case $line[4] in
                                    generate)

                                        # ---- Command: help _meta pod generate
                                        _arguments -s -C \
                                            '1: :->cmd1' \
                                            '2: :->cmd2' \
                                            '3: :->cmd3' \
                                            '4: :->cmd4' \
                                            '--help[Show command help]' \
                                            '-h[Show command help]' \
                                            '--all[]' \
                                            && ret=0


                                    ;;
                                    esac

                                ;;

                                esac
                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    diff)

                        # ---- Command: help diff
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--all[]' \
                            && ret=0


                    ;;
                    features)

                        # ---- Command: help features
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--all[]' \
                            && ret=0


                    ;;
                    module)

                        # ---- Command: help module
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--all[]' \
                            && ret=0


                    ;;
                    modules)

                        # ---- Command: help modules
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--all[]' \
                            && ret=0


                    ;;
                    perl)

                        # ---- Command: help perl
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--all[]' \
                            && ret=0


                    ;;
                    esac

                ;;

                esac
            ;;
            module)

                # ---- Command: module
                _arguments -s -C \
                    '1: :->cmd1' \
                    '2: :->module' \
                    '--help[Show command help]' \
                    '-h[Show command help]' \
                    '--all[Show all perl and module versions]' \
                    '-a[Show all perl and module versions]' \
                    '--date[Show by date]' \
                    '-d[Show by date]' \
                    '--perl[Show by Perl Version]:perl:_pcorelist_module_option_perl_completion' \
                    '-p[Show by Perl Version]:perl:_pcorelist_module_option_perl_completion' \
                    && ret=0

                case $state in
                module)
_pcorelist_module_param_module_completion
                ;;
                esac

            ;;
            modules)

                # ---- Command: modules
                _arguments -s -C \
                    '1: :->cmd1' \
                    '--help[Show command help]' \
                    '-h[Show command help]' \
                    && ret=0


            ;;
            perl)

                # ---- Command: perl
                _arguments -s -C \
                    '1: :->cmd1' \
                    '--help[Show command help]' \
                    '-h[Show command help]' \
                    '--raw[Show raw output without header]' \
                    '-r[Show raw output without header]' \
                    '--release[Show perl releases with dates]' \
                    && ret=0


            ;;
            esac

        ;;

        esac

}

_pcorelist_diff_param_perl1_completion() {
    local __dynamic_completion
    local CURRENT_WORD="$words[CURRENT]"
    IFS=$'\n' __dynamic_completion=( $( $program 'perl' '--raw' ) )
    compadd -X "perl1:" $__dynamic_completion
}
_pcorelist_diff_param_perl2_completion() {
    local __dynamic_completion
    local CURRENT_WORD="$words[CURRENT]"
    IFS=$'\n' __dynamic_completion=( $( $program 'perl' '--raw' ) )
    compadd -X "perl2:" $__dynamic_completion
}
_pcorelist_features_param_feature_completion() {
    local __dynamic_completion
    local CURRENT_WORD="$words[CURRENT]"
    IFS=$'\n' __dynamic_completion=( $( $program 'features' '--raw' ) )
    compadd -X "feature:" $__dynamic_completion
}
_pcorelist_module_param_module_completion() {
    local __dynamic_completion
    local CURRENT_WORD="$words[CURRENT]"
    IFS=$'\n' __dynamic_completion=( $( $program 'modules' ) )
    compadd -X "module:" $__dynamic_completion
}
_pcorelist_module_option_perl_completion() {
    local __dynamic_completion
    local CURRENT_WORD="$words[CURRENT]"
    IFS=$'\n' __dynamic_completion=( $( $program 'perl' '--raw' ) )
    compadd -X "perl:" $__dynamic_completion
}

__pcorelist_dynamic_comp() {
    local argname="$1"
    local arg="$2"
    local comp="arg:$argname:(("
    local line
    while read -r line; do
        local name="$line"
        local desc="$line"
        name="${name%$'\t'*}"
        desc="${desc/*$'\t'}"
        comp="$comp$name"
        if [[ -n "$desc" && "$name" != "$desc" ]]; then
            comp="$comp\\:"'"'"$desc"'"'
        fi
        comp="$comp "
    done <<< "$arg"

    comp="$comp))"
    _alternative "$comp"
}

