Debian Codegraph @

tools/watcher.bash_completion

raw
1 _watcher_opts="" # lazy init
2 _watcher_flags="" # lazy init
3 _watcher_opts_exp="" # lazy init
4 _watcher()
5 {
6 local cur prev nbc cflags
7 COMPREPLY=()
8 cur="${COMP_WORDS[COMP_CWORD]}"
9 prev="${COMP_WORDS[COMP_CWORD-1]}"
10
11 if [ "x$_watcher_opts" == "x" ] ; then
12 nbc="`watcher bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
13 _watcher_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
14 _watcher_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
15 _watcher_opts_exp="`echo "$_watcher_opts" | tr ' ' '|'`"
16 fi
17
18 if [[ " ${COMP_WORDS[@]} " =~ " "($_watcher_opts_exp)" " && "$prev" != "help" ]] ; then
19 COMPLETION_CACHE=$HOME/.cache/python-watcherclient/*/*-cache
20 cflags="$_watcher_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
21 COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
22 else
23 COMPREPLY=($(compgen -W "${_watcher_opts}" -- ${cur}))
24 fi
25 return 0
26 }
27 complete -F _watcher watcher