iopsys-feed/iop/iop.completion
Ronny Nilsson b098ef3dc2 Add support for TaaS smoketesting of images.
For developers and Jenkins etc. A short hand command for
testing the just built image on real hardware. To be
used before pushing commits and nightly images to public.
2020-10-28 16:11:26 +01:00

94 lines
2.6 KiB
Text

# Bash completion for IOPSYS "./iop" utility
# Source this file into the curent shell or copy it into
# /usr/share/bash-completion/completions/ and start a new shell
# for automatic availability.
_iop_get_profiles()
{
find feeds/targets/iopsys-*/ -name '*.diff' \
|awk -F'/' '{print$NF}' \
|awk -F. '{print$1}'
}
_iop_get_models()
{
find feeds/targets/iopsys-*/ -mindepth 1 -maxdepth 1 -type d \
|awk -F'/' '{print$NF}' \
|egrep '^(cg|dg|eg|vg|vox)[0-9]'
}
_iop_get_model_customers()
{
local model=$1
find customerconfigs/$prev -mindepth 1 -maxdepth 1 -type d \
|awk -F'/' '{print$NF}'
}
_iop()
{
local cur prev iopcmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
iopcmds="bootstrap cfe_upgrade cfe_upgrade_latest extract_core \
feeds_update genconfig generate_tarballs install_key \
scp_changes setup_host ssh_install_key status \
update_package update_feed_branches ssh_upgrade smoketest"
if [ $COMP_CWORD -eq 1 ] ; then
# Complete the primary iop command
COMPREPLY=($(compgen -W "${iopcmds}" -- ${cur}))
return 0
else
# Complete the arguments to "iopcmds"
local cmd="${COMP_WORDS[1]}"
case "$cmd" in
extract_core)
if [ "$prev" == "-e" ] ; then
_filedir -d
else
COMPREPLY=( $(compgen -W "-e -h" -- ${cur}) )
fi
return 0
;;
genconfig)
if [ "$prev" == "-p" ] ; then
local profiles=$(_iop_get_profiles)
COMPREPLY=( $(compgen -W "juci $profiles" -- ${cur}) )
elif [[ $cur == -* ]] ; then
COMPREPLY=( $(compgen -W "-c -h -p -s -t -u -v" -- ${cur}) )
else
local models=$(_iop_get_models)
if echo $models |grep -qw -- $prev ; then
local customers=$(_iop_get_model_customers $prev)
COMPREPLY=( $(compgen -W "$customers" -- ${cur}) )
else
COMPREPLY=( $(compgen -W "$models" -- ${cur}) )
fi
fi
return 0
;;
ssh_upgrade)
if [ "$prev" == "-f" ] ; then
_filedir
else
COMPREPLY=( $(compgen -W "-f -t -i -n -x -b" -- ${cur}) )
fi
;;
*)
# No arguments or arguments not supported yet
;;
esac
fi
}
complete -F _iop ./iop
complete -F _iop iop