- group subcommands of `rally verify` subcommand - put proper descirptions for rally categories - log deprecation warning on `rally deployment` commands execution - deprecate all --deployment arguments in favor of --env Change-Id: I94ed1f37e59ae266affe45fc7c8a5077923d40cb Signed-off-by: Andriy Kurilin <andr.kurilin@gmail.com>
108 lines
4.1 KiB
Bash
108 lines
4.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Standalone _filedir() alternative.
|
|
# This exempts from dependence of bash completion routines
|
|
function _rally_filedir()
|
|
{
|
|
test "${1}" \
|
|
&& COMPREPLY=( \
|
|
$(compgen -f -- "${cur}" | grep -E "${1}") \
|
|
$(compgen -o plusdirs -- "${cur}") ) \
|
|
|| COMPREPLY=( \
|
|
$(compgen -o plusdirs -f -- "${cur}") \
|
|
$(compgen -d -- "${cur}") )
|
|
}
|
|
|
|
_rally()
|
|
{
|
|
declare -A SUBCOMMANDS
|
|
declare -A OPTS
|
|
|
|
OPTS["db_create"]=""
|
|
OPTS["db_ensure"]=""
|
|
OPTS["db_recreate"]=""
|
|
OPTS["db_revision"]=""
|
|
OPTS["db_show"]="--creds"
|
|
OPTS["db_upgrade"]=""
|
|
OPTS["deployment_check"]=""
|
|
OPTS["deployment_config"]=""
|
|
OPTS["deployment_create"]="--name --fromenv --filename --no-use"
|
|
OPTS["deployment_destroy"]=""
|
|
OPTS["deployment_list"]=""
|
|
OPTS["deployment_recreate"]="--filename"
|
|
OPTS["deployment_show"]=""
|
|
OPTS["deployment_use"]=""
|
|
OPTS["env_check"]="--json --detailed"
|
|
OPTS["env_cleanup"]="--json"
|
|
OPTS["env_create"]="--name --description --extras --spec --from-sysenv --json --no-use"
|
|
OPTS["env_delete"]="--force"
|
|
OPTS["env_destroy"]="--skip-cleanup --json --detailed"
|
|
OPTS["env_info"]="--json"
|
|
OPTS["env_list"]="--json"
|
|
OPTS["env_show"]="--json --only-spec"
|
|
OPTS["env_use"]="--json"
|
|
OPTS["plugin_list"]="--platform --plugin-base"
|
|
OPTS["plugin_show"]="--platform"
|
|
OPTS["task_abort"]="--soft"
|
|
OPTS["task_delete"]="--force"
|
|
OPTS["task_detailed"]="--iterations-data --filter-by"
|
|
OPTS["task_export"]="--type --to --env"
|
|
OPTS["task_import"]="--file --env --tag"
|
|
OPTS["task_list"]="--env --all-envs --status --tag --uuids-only"
|
|
OPTS["task_report"]="--out --open --html --html-static --json --env"
|
|
OPTS["task_restart"]="--env --scenario --tag --no-use --abort-on-sla-failure"
|
|
OPTS["task_results"]=""
|
|
OPTS["task_sla-check"]="--json"
|
|
OPTS["task_start"]="--env --task-args --task-args-file --tag --no-use --abort-on-sla-failure"
|
|
OPTS["task_status"]=""
|
|
OPTS["task_trends"]="--out --open --html-static"
|
|
OPTS["task_use"]=""
|
|
OPTS["task_validate"]="--env --task-args --task-args-file"
|
|
OPTS["verify_add-verifier-ext"]="--source --extra-settings"
|
|
OPTS["verify_configure-verifier"]="--env --reconfigure --extend --override --show"
|
|
OPTS["verify_create-verifier"]="--name --type --platform --source --system-wide --extra-settings --no-use"
|
|
OPTS["verify_delete"]=""
|
|
OPTS["verify_delete-verifier"]="--env --force"
|
|
OPTS["verify_delete-verifier-ext"]="--name"
|
|
OPTS["verify_import"]="--env --file --run-args --no-use"
|
|
OPTS["verify_list"]="--id --env --tag --status"
|
|
OPTS["verify_list-plugins"]="--platform"
|
|
OPTS["verify_list-verifier-exts"]=""
|
|
OPTS["verify_list-verifier-tests"]="--pattern"
|
|
OPTS["verify_list-verifiers"]="--status"
|
|
OPTS["verify_report"]="--type --to --open"
|
|
OPTS["verify_rerun"]="--env --failed --tag --concurrency --detailed --no-use"
|
|
OPTS["verify_show"]="--sort-by --detailed"
|
|
OPTS["verify_show-verifier"]=""
|
|
OPTS["verify_start"]="--env --tag --pattern --concurrency --load-list --skip-list --xfail-list --detailed --no-use"
|
|
OPTS["verify_update-verifier"]="--update-venv --system-wide --no-system-wide"
|
|
OPTS["verify_use"]=""
|
|
OPTS["verify_use-verifier"]=""
|
|
for OPT in ${!OPTS[*]} ; do
|
|
CMD=${OPT%%_*}
|
|
CMDSUB=${OPT#*_}
|
|
SUBCOMMANDS[${CMD}]+="${CMDSUB} "
|
|
done
|
|
|
|
COMMANDS="${!SUBCOMMANDS[*]}"
|
|
COMPREPLY=()
|
|
|
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
|
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
if [[ $cur =~ ^(\.|\~|\/) ]] || [[ $prev =~ ^--out(|put-file)$ ]] ; then
|
|
_rally_filedir
|
|
elif [[ $prev =~ ^--(task|filename)$ ]] ; then
|
|
_rally_filedir "\.json|\.yaml|\.yml"
|
|
elif [ $COMP_CWORD == "1" ] ; then
|
|
COMPREPLY=($(compgen -W "$COMMANDS" -- ${cur}))
|
|
elif [ $COMP_CWORD == "2" ] ; then
|
|
COMPREPLY=($(compgen -W "${SUBCOMMANDS[${prev}]}" -- ${cur}))
|
|
else
|
|
COMMAND="${COMP_WORDS[1]}_${COMP_WORDS[2]}"
|
|
COMPREPLY=($(compgen -W "${OPTS[$COMMAND]}" -- ${cur}))
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
complete -o filenames -F _rally rally |