forked from lukaszgard/bitbake-completion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbake_prserv_completion
64 lines (54 loc) · 1.57 KB
/
bitbake_prserv_completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!bash
# Bash completion support for bitbake-prserv tool,
# compatible with Bitbake 1.40.1.
#
# Copyright (C) 2018 Lukasz Gardon <[email protected]>
#
# Distributed under the MIT License (MIT)
#
_bitbake_prserv()
{
local cur prev opts_short opts_long file_default log_default log_levels
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts_short="-h -f -l"
opts_long="--version --help --file= --log= --loglevel= --start \
--stop --host= --port="
file_default="prserv.sqlite3"
log_default="prserv.log"
log_levels="CRITICAL ERROR WARNING INFO DEBUG"
if [[ "$prev" == "=" ]]; then
prev="${COMP_WORDS[COMP_CWORD -2]}"
elif [[ "$cur" == "=" ]]; then
cur=""
fi
case "$prev" in
"-f"|"--file")
COMPREPLY=( $(compgen -W "${file_default}" -- ${cur}) )
return 0
;;
"-l"|"--log")
COMPREPLY=( $(compgen -W "${log_default}" -- ${cur}) )
return 0
;;
"--loglevel")
COMPREPLY=( $(compgen -W "${log_levels}" -- ${cur}) )
return 0
;;
esac
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == "--"*"=" ]] ; then
compopt -o nospace
fi
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
return 0
;;
esac
}
complete -F _bitbake_prserv bitbake-prserv