API-CLI

 view release on metacpan or  search on metacpan

share/completion/bash/apicli.bash  view on Meta::CPAN


# http://stackoverflow.com/questions/7267185/bash-autocompletion-add-description-for-possible-completions

_apicli() {

    COMPREPLY=()
    local program=apicli
    local cur=${COMP_WORDS[$COMP_CWORD]}
#    echo "COMP_CWORD:$COMP_CWORD cur:$cur" >>/tmp/comp
    declare -a FLAGS
    declare -a OPTIONS
    declare -a MYWORDS

    local INDEX=`expr $COMP_CWORD - 1`
    MYWORDS=("${COMP_WORDS[@]:1:$COMP_CWORD}")

    FLAGS=('--help' 'Show command help' '-h' 'Show command help')
    OPTIONS=()
    __apicli_handle_options_flags

    case $INDEX in

    0)
        __comp_current_options || return
        __apicli_dynamic_comp 'commands' 'appspec'$'\t''Generate App::Spec file'$'\n''help'$'\t''Show command help'

    ;;
    *)
    # subcmds
    case ${MYWORDS[0]} in
      _meta)
        FLAGS+=()
        OPTIONS+=()
        __apicli_handle_options_flags
        case $INDEX in

        1)
            __comp_current_options || return
            __apicli_dynamic_comp 'commands' 'completion'$'\t''Shell completion functions'$'\n''pod'$'\t''Pod documentation'

        ;;
        *)
        # subcmds
        case ${MYWORDS[1]} in
          completion)
            FLAGS+=()
            OPTIONS+=()
            __apicli_handle_options_flags
            case $INDEX in

            2)
                __comp_current_options || return
                __apicli_dynamic_comp 'commands' 'generate'$'\t''Generate self completion'

            ;;
            *)
            # subcmds
            case ${MYWORDS[2]} in
              generate)
                FLAGS+=('--zsh' 'for zsh' '--bash' 'for bash')
                OPTIONS+=('--name' 'name of the program (optional, override name in spec)')
                __apicli_handle_options_flags
                  case $INDEX in
                  *)
                    __comp_current_options true || return # after parameters
                    case ${MYWORDS[$INDEX-1]} in
                      --name)
                      ;;

                    esac
                    ;;
                esac
              ;;
            esac

            ;;
            esac
          ;;
          pod)
            FLAGS+=()
            OPTIONS+=()
            __apicli_handle_options_flags
            case $INDEX in

            2)
                __comp_current_options || return
                __apicli_dynamic_comp 'commands' 'generate'$'\t''Generate self pod'

            ;;
            *)
            # subcmds
            case ${MYWORDS[2]} in
              generate)
                FLAGS+=()
                OPTIONS+=()
                __apicli_handle_options_flags
                __comp_current_options true || return # no subcmds, no params/opts
              ;;
            esac

            ;;
            esac
          ;;
        esac

        ;;
        esac
      ;;
      appspec)
        FLAGS+=()
        OPTIONS+=('--from' 'Currently only '"'"'openapi'"'"' is supported' '--out' 'Output file (default stdout)' '--name' 'appname' '--class' 'Class name (default API::CLI)')
        __apicli_handle_options_flags
          case $INDEX in
          1)
              __comp_current_options || return
          ;;
          *)
            __comp_current_options true || return # after parameters
            case ${MYWORDS[$INDEX-1]} in
              --from)
              ;;



( run in 0.614 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )