yvoronoy/m2install

View on GitHub
m2install-bash-completion

Summary

Maintainability
Test Coverage
#
# Completion for m2install
#
_m2install()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="--help -h --source -s --force -f --sample-data --step --ee-path --ee --git-branch --mode --quiet --php --code-dump --db-dump --debug --skip-post-deploy --restore-table";

    case "$prev" in 
        --source)
            COMPREPLY=( $(compgen -W "git composer" ${cur}) )
            return 0;
        ;;
        -s)
            COMPREPLY=( $(compgen -W "git composer" ${cur}) )
            return 0;
        ;;
        --sample-data)
            COMPREPLY=( $(compgen -W "yes no" ${cur}) )
            return 0;
        ;;
        --ee-path)
            COMPREPLY=( $(compgen -W "$(ls -d */ 2>/dev/null)" ${cur}) )
            return 0;
        ;;
        --git-branch)
            COMPREPLY=( $(compgen -W "$(git branch | sed s/*//g)" ${cur}) )
            return 0;
        ;;
        --mode)
            COMPREPLY=( $(compgen -W "dev prod" ${cur}) )
            return 0;
        ;;
        --php)
            COMPREPLY=( $(compgen -W "php71" ${cur}) )
            return 0;
        ;;
        --code-dump)
            COMPREPLY=( $(compgen -f ${cur}) )
            return 0;
        ;;
        --db-dump)
            COMPREPLY=( $(compgen -f ${cur}) )
            return 0;
        ;;
        --step)
            COMPREPLY=( $(compgen -W "restore_code restore_db configure_db configure_files" ${cur}) )
            return 0;
        ;;
        --restore-table)
            COMPREPLY=( $(compgen -W "table-name" ${cur}) )
            return 0;
    esac

    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _m2install m2install.sh