HOME


sh-3ll 1.0
DIR:/proc/self/root/usr/local/interworx/contrib/
Upload File :
Current File : //proc/self/root/usr/local/interworx/contrib/iworx-completion.sh
#!/bin/sh

_nodeworx()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    if [[ ${prev} == nodeworx ]] ; then
        opts="--help --session-id --user-auth --interactive --non-interactive --verbose --output-style"
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi

    if [[ ${prev} == siteworx ]] ; then
        opts="--help --session-id --user-auth --interactive --non-interactive --verbose --output-style --login_domain"
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
    unset COMP_WORDS[${#COMP_WORDS[@]}-1]
    COMP_WORDS[0]="${COMP_WORDS[0]} -hn"
    output="`${COMP_WORDS[@]} -h`"

    if [[ ${prev} == -c || ${prev} == --controller ]] ; then
        opts=`echo "${output}" | grep '\-\-controller' | awk '{print $3}' | sed 's/|/ /g'`
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi

    if [[ ${prev} == -a || ${prev} == --action ]] ; then
        opts=`echo "${output}" | grep '\-\-action' | awk '{print $3}' | sed 's/|/ /g'`
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi

    if [[ ${prev} == --* ]] ; then
        opts=`echo "${output}" | grep -- "${prev}" | grep \< | grep \> | awk '{print $3}' | sed 's/|/ /g'`
        if ! [[ -z ${opts} ]] ; then
            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
            return 0
        fi

    fi

    opts=`echo "${output}" | grep '\-\-' | awk '{print $1}' | sed 's/|/ /' | awk '{print $1}' | grep -A9999 output-style | grep -v '\-\-output-style' | xargs echo`
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}

complete -F _nodeworx nodeworx

complete -F _nodeworx siteworx