/
githubmirror
/
toolbox
Обзор
Документация
Войти
/
githubmirror
/
toolbox
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
0.0.90
completion/bash/toolbox
76 строк
2 KB
Harry Míchal
Add a --very-verbose or -vv option
19 ноя 2019, 15:38
19 ноя 2019, 15:38
1625ad3
Код
Авторство
О чём код?
# Check for bash [ -z "$BASH_VERSION" ] && return __toolbox_containers() { podman ps --all --format '{{.Names}}' } __toolbox_images() { podman images --format '{{.Repository}}:{{.Tag}}' } __toolbox() { local MIN_VERSION=29 local RAWHIDE_VERSION=32 local commands="create enter help init-container list reset rm rmi run" declare -A options local options=([create]="--candidate-registry --container --image --release" \ [enter]="--container --release" \ [help]="$commands" \ [init-container]="--home --home-link --monitor-host --shell --uid --user" \ [list]="--containers --images" \ [rm]="--all --force" \ [rmi]="--all --force" \ [run]="--container --release") _init_completion -s || return if [ "${COMP_CWORD}" -eq 1 ]; then mapfile -t COMPREPLY < <(compgen -W "--assumeyes --help --verbose --very-verbose $commands" -- "$2") return 0 fi case "$prev" in --verbose | -v | --very-verbose | -vv) mapfile -t COMPREPLY < <(compgen -W "$commands" -- "$2") return 0 ;; --container | -c) mapfile -t COMPREPLY < <(compgen -W "$(__toolbox_containers)" -- "$2") return 0 ;; --image | -i) mapfile -t COMPREPLY < <(compgen -W "$(__toolbox_images)" -- "$2") return 0 ;; --release | -r) mapfile -t COMPREPLY < <(compgen -W "$(seq $MIN_VERSION $RAWHIDE_VERSION)" -- "$2") return 0 ;; esac local command if [ "${COMP_WORDS[1]}" = --verbose ] || [ "${COMP_WORDS[1]}" = --very-verbose ]; then command=${COMP_WORDS[2]} else command=${COMP_WORDS[1]} fi local extra_comps case "$command" in rm) extra_comps="$(__toolbox_containers)" ;;& rmi) extra_comps="$(__toolbox_images)" ;;& *) mapfile -t COMPREPLY < <(compgen -W "${options[$command]} $extra_comps" -- "$2") return 0; ;; esac } complete -F __toolbox toolbox