Skip to content

Commit

Permalink
Zsh tab completion can be configured for v1 or v2
Browse files Browse the repository at this point in the history
  • Loading branch information
snim2 committed Nov 4, 2024
1 parent 3d19baf commit 139939f
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions support/zsh-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
;;

*)
Expand Down

0 comments on commit 139939f

Please sign in to comment.