-
Notifications
You must be signed in to change notification settings - Fork 10
/
slapd-cli-prompt
33 lines (29 loc) · 1.23 KB
/
slapd-cli-prompt
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
_slapd-cli()
{
local CUR PREV ACTIONS
COMPREPLY=()
CUR="${COMP_WORDS[COMP_CWORD]}"
PREV="${COMP_WORDS[COMP_CWORD-1]}"
ACTIONS="start stop forcestop restart debug force-restart status configtest reindex backup restore hotrestore backupconfig restoreconfig hotrestoreconfig checksync importflatconfigtemplate importldifconfigtemplate convertconfig buildconfigtemplate importdatatemplate lloadstart lloadstop lloadstatus removeoldbackups"
if [[ ${COMP_WORDS[*]} == *"convertconfig"* ]] || [[ ${COMP_WORDS[*]} == *"buildconfigtemplate"* ]] ; then
# if the action requires a filename, autocomplete with a filename
if [[ $( type -t _longopt ) == function ]] ; then
# better filename competion with function _longopt
_longopt
else
COMPREPLY=( $(compgen -f -- ${CUR}) )
fi
return 0
else
for A in ${ACTIONS} ; do
if [[ ${COMP_WORDS[*]} == *"${A}"* ]] ; then
# Don't autocomplete if we already have a valid action
return 0
fi
done
# Autocomplete with given actions
COMPREPLY=( $(compgen -W "${ACTIONS}" -- ${CUR}) )
return 0
fi
}
complete -F _slapd-cli slapd-cli