limenka-cli.footer.zsh-completion raw
1 # Handle current word completions
2 case "$words[CURRENT]" in
3 -conf=*)
4 local conf_path=${words[CURRENT]#-conf=}
5 _files -W ${conf_path:h} -g "*"
6 return 0
7 ;;
8 -datadir=*)
9 local datadir_path=${words[CURRENT]#-datadir=}
10 _files -/ -W ${datadir_path:h}
11 return 0
12 ;;
13 -*=*)
14 # prevent nonsense completions
15 return 0
16 ;;
17 *)
18 local helpopts commands
19 local -a opts
20
21 # only parse -help if sensible (empty or starts with -)
22 if [[ -z "$words[CURRENT]" || "$words[CURRENT]" == -* ]]; then
23 helpopts="$($limenka_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }')"
24 opts+=(${(f)helpopts})
25 fi
26
27 # only parse help if sensible (empty or starts with letter)
28 if [[ -z "$words[CURRENT]" || "$words[CURRENT]" == [a-z]* ]]; then
29 commands="$(_limenka_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')"
30 opts+=(${(f)commands})
31 fi
32
33 _describe 'limenka-cli options and commands' opts
34
35 return 0
36 ;;
37 esac
38 }
39
40 # Function is now defined and will be called by zsh completion system
41
42 # Local variables:
43 # mode: shell-script
44 # sh-basic-offset: 4
45 # sh-indent-comment: t
46 # indent-tabs-mode: nil
47 # End:
48 # ex: ts=4 sw=4 et filetype=sh
49