opencafe/scripts/cafe-completion

49 lines
1.8 KiB
Plaintext

_cafe_runner()
{
local cur options
COMPREPLY=()
#get current word. sed for windows backslash
cur=$(echo "${COMP_WORDS[COMP_CWORD]}"|sed 's/\\/\\\\/g')
if [[ ${cur} == -* ]]; then
options='--help --test-repo --verbose --fail-fast --supress-load-tests --packages --module-regex --module --method-regex --tags --result --result-directory --parallel --dry-run --data-directory --data --list'
elif [[ ${COMP_CWORD} < 2 ]]; then
options=$(python -c "from cafe.drivers.unittest.autocomplete import print_products;print_products()" 2>/dev/null)
else
options=$(python -c "from cafe.drivers.unittest.autocomplete import print_configs_by_product;print_configs_by_product(\"${COMP_WORDS[1]}\")" 2>/dev/null)
fi
options=$(echo $options|sed 's/\\/\\\\/g')
COMPREPLY=( $(compgen -W '${options}' -- ${cur}) )
return 0
}
_cafe_parallel()
{
local cur options
COMPREPLY=()
#get current word. sed for windows backslash
cur=$(echo "${COMP_WORDS[COMP_CWORD]}"|sed 's/\\/\\\\/g')
if [[ ${cur} == -* ]]; then
options='--help --dry-run --exit-on-error --list --data-directory --regex-list --file --parallel --result --result-directory --tags --verbose --workers'
COMPREPLY="${COMPREPLY} "
elif [[ ${COMP_CWORD} < 2 ]]; then
options=$(python -c "from cafe.drivers.unittest.autocomplete import print_configs;print_configs()" 2>/dev/null)
COMPREPLY="${COMPREPLY} "
else
options=$(python -c "from cafe.drivers.unittest.autocomplete import print_imports;print_imports(\"${cur}\")" 2>/dev/null)
fi
#sed for windows backslash
options=$(echo $options|sed 's/\\/\\\\/g')
COMPREPLY=( $(compgen -W '${options}' -- ${cur}) )
return 0
}
complete -F _cafe_runner cafe-runner
complete -o nospace -F _cafe_parallel cafe-parallel