diff --git a/support/zsh-completion.sh b/support/zsh-completion.sh index a59cd3c..869629f 100755 --- a/support/zsh-completion.sh +++ b/support/zsh-completion.sh @@ -26,53 +26,61 @@ _dalmatian_completions() { dir=$(command -v "dalmatian") bindir=$(dirname "$dir") + local version="v1" + local config_dir="$HOME/.config/dalmatian" + local config_version_json_file="$config_dir/version.json" + if [ -f "$config_version_json_file" ] + then + version=$(jq -r '.version' < "$config_version_json_file") + fi + case "$compline" in 'aurora'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/aurora/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/aurora/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'certificate'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/certificate/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/certificate/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'cloudfront'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/cloudfront/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/cloudfront/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'service'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/service/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/service/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'config') - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/config/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/config/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'util'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/util/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/util/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'rds'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/rds/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/rds/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'ecs'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/ecs/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/ecs/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'waf'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/waf/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/waf/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'aws'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/aws/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/aws/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'ci'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/ci/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/ci/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; 'elasticache'*) - while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/elasticache/v1" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) + while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_dalmatian_completions_filter "$(find "$bindir/elasticache/$version" -type f -mindepth 1 -maxdepth 1 -exec basename {} \;)")" -- "$cur" ) ;; *)