baz-example-plugin/plugin/functions/__baz_comp
Ari Archer a30971fca0
update @ Sat 21 May 10:42:31 EEST 2022
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-05-21 10:42:31 +03:00

19 lines
1.4 KiB
Bash

#!/usr/bin/env bash
_init_completion -s || return
local cur=${COMP_WORDS[COMP_CWORD]}
local comp_line="${COMP_WORDS[@]:1}"
case "$comp_line" in
'install local'*) COMPREPLY=($(compgen -A directory -- "$cur")) ;;
'install git'*) COMPREPLY=($(compgen -W "git:// https:// git+https:// http:// git+http://" -- "$cur")) ;;
'info exist'*) COMPREPLY=($(compgen -W "$([ -d "$HOME/.local/share/baz/plugins" ] && find "$HOME/.local/share/baz/plugins" -maxdepth 1 -not -path . -and -not -path "$HOME/.local/share/baz/plugins" -type d -exec basename {} \;)" -- "$cur")) ;;
'info local'*) COMPREPLY=($(compgen -A directory -- "$cur")) ;;
'uninstall'*) COMPREPLY=($(compgen -W "$([ -d "$HOME/.local/share/baz/plugins" ] && find "$HOME/.local/share/baz/plugins" -maxdepth 1 -not -path . -and -not -path "$HOME/.local/share/baz/plugins" -type d -exec basename {} \;)" -- "$cur")) ;;
'info git'*) COMPREPLY=($(compgen -W "git:// https:// git+https:// http:// git+http://" -- "$cur")) ;;
'install'*) COMPREPLY=($(compgen -W "local git" -- "$cur")) ;;
'update'*) COMPREPLY=($(compgen -W "$([ -d "$HOME/.local/share/baz/plugins" ] && find "$HOME/.local/share/baz/plugins" -maxdepth 1 -not -path . -and -not -path "$HOME/.local/share/baz/plugins" -type d -exec basename {} \;)" -- "$cur")) ;;
'info'*) COMPREPLY=($(compgen -W "exist local git" -- "$cur")) ;;
''*) COMPREPLY=($(compgen -W "help setup unsetup install uninstall list update info upgrade version" -- "$cur")) ;;
esac