#compdef metacpancl

_metacpancl() {
    local program=metacpancl
    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:((GET\:"GET call" POST\:"POST call" help\:"Show command help"))'
        ;;

        args)
            case $line[1] in
            GET)

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


                case $state in
                cmd2)
                    _alternative 'args:cmd3:((/author/\\:author\:"Author information" /distribution/\\:distribution\:"Distribution information not specific to a version..." /module/\\:module\:"Module information" /pod/\\:module\:"Module POD" /release/\\:author/\\:release\:"Release information" /release/\\:distribution\:"Release information" /release/_search\:"Search releases"))'
                ;;

                args)
                    case $line[2] in
                    /author/:author)

                        # ---- Command: GET /author/:author
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->author' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            && ret=0

                        case $state in
                        author)

                        ;;
                        esac

                    ;;
                    /distribution/:distribution)

                        # ---- Command: GET /distribution/:distribution
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->distribution' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            && ret=0

                        case $state in
                        distribution)

                        ;;
                        esac

                    ;;
                    /module/:module)

                        # ---- Command: GET /module/:module
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->module' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            && ret=0

                        case $state in
                        module)

                        ;;
                        esac

                    ;;
                    /pod/:module)

                        # ---- Command: GET /pod/:module
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->module' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--q-content-type[Default is text/html]:q-content-type:("text/html" "text/plain" "text/x-pod" "text/x-markdown")' \
                            && ret=0

                        case $state in
                        module)

                        ;;
                        esac

                    ;;
                    /release/:author/:release)

                        # ---- Command: GET /release/:author/:release
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->author' \
                            '4: :->release' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            && ret=0

                        case $state in
                        author)

                        ;;
                        release)

                        ;;
                        esac

                    ;;
                    /release/:distribution)

                        # ---- Command: GET /release/:distribution
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '3: :->distribution' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            && ret=0

                        case $state in
                        distribution)

                        ;;
                        esac

                    ;;
                    /release/_search)

                        # ---- Command: GET /release/_search
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            '--q-q[query ("author:ANDK AND status:latest")]:q-q' \
                            '--q-fields[resultset fields]:q-fields' \
                            '--q-size[how many results]:q-size' \
                            && ret=0


                    ;;
                    esac

                ;;

                esac
            ;;
            POST)

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


                case $state in
                cmd2)
                    _alternative 'args:cmd3:((/file\:"file"))'
                ;;

                args)
                    case $line[2] in
                    /file)

                        # ---- Command: POST /file
                        _arguments -s -C \
                            '1: :->cmd1' \
                            '2: :->cmd2' \
                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                            '--debug[debug]' \
                            '-d[debug]' \
                            '--verbose[verbose]' \
                            '-v[verbose]' \
                            '--help[Show command help]' \
                            '-h[Show command help]' \
                            && ret=0


                    ;;
                    esac

                ;;

                esac
            ;;
            _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' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--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' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    && ret=0


                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    esac

                ;;

                esac
            ;;
            help)

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


                case $state in
                cmd2)
                    _alternative 'args:cmd3:((GET POST))'
                ;;

                args)
                    case $line[2] in
                    GET)

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


                        case $state in
                        cmd3)
                            _alternative 'args:cmd4:((/author/\\:author /distribution/\\:distribution /module/\\:module /pod/\\:module /release/\\:author/\\:release /release/\\:distribution /release/_search))'
                        ;;

                        args)
                            case $line[3] in
                            /author/:author)

                                # ---- Command: help GET /author/:author
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            /distribution/:distribution)

                                # ---- Command: help GET /distribution/:distribution
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            /module/:module)

                                # ---- Command: help GET /module/:module
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            /pod/:module)

                                # ---- Command: help GET /pod/:module
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            /release/:author/:release)

                                # ---- Command: help GET /release/:author/:release
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            /release/:distribution)

                                # ---- Command: help GET /release/:distribution
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            /release/_search)

                                # ---- Command: help GET /release/_search
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    POST)

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


                        case $state in
                        cmd3)
                            _alternative 'args:cmd4:((/file))'
                        ;;

                        args)
                            case $line[3] in
                            /file)

                                # ---- Command: help POST /file
                                _arguments -s -C \
                                    '1: :->cmd1' \
                                    '2: :->cmd2' \
                                    '3: :->cmd3' \
                                    '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                    '--debug[debug]' \
                                    '-d[debug]' \
                                    '--verbose[verbose]' \
                                    '-v[verbose]' \
                                    '--help[Show command help]' \
                                    '-h[Show command help]' \
                                    '--all[]' \
                                    && ret=0


                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    _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' \
                                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                            '--debug[debug]' \
                                            '-d[debug]' \
                                            '--verbose[verbose]' \
                                            '-v[verbose]' \
                                            '--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' \
                                            '--data-file[File with data for POST/PUT/PATCH/DELETE requests]:data-file:_files' \
                                            '--debug[debug]' \
                                            '-d[debug]' \
                                            '--verbose[verbose]' \
                                            '-v[verbose]' \
                                            '--help[Show command help]' \
                                            '-h[Show command help]' \
                                            '--all[]' \
                                            && ret=0


                                    ;;
                                    esac

                                ;;

                                esac
                            ;;
                            esac

                        ;;

                        esac
                    ;;
                    esac

                ;;

                esac
            ;;
            esac

        ;;

        esac

}


__metacpancl_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"
}

