Add bash completion support. Fix #283

This commit is contained in:
Hackerpilot 2016-01-19 19:37:10 -08:00
parent 82ecc2d27a
commit 35e24667f0
3 changed files with 62 additions and 2 deletions

4
.gitignore vendored
View File

@ -5,8 +5,8 @@
*.dll
# *nix binaries
dcd-client
dcd-server
bin/dcd-client
bin/dcd-server
*.o
*.a
*.so

View File

@ -0,0 +1,28 @@
# Completion for dcd-client
_dcd_client()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help -h --cursorPos -c --shutdown --symbolLocation -l --doc -d\
--search -s --query -q --status -I --version --port -p --tcp --socketFile"
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0;
fi
case "${prev}" in
"-I")
COMPREPLY=($(compgen -d ${cur}))
return 0
;;
"--socketFile")
COMPREPLY=($(compgen -f ${cur}))
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
}
complete -F _dcd_client "dcd-client"

View File

@ -0,0 +1,32 @@
# Completion for dcd-server
_dcd_server()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-I --help -h --version --logLevel --tcp --socketFile"
logLevels="all trace info warning error critical fatal off"
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0;
fi
case "${prev}" in
"-I")
COMPREPLY=($(compgen -d ${cur}))
return 0
;;
"--logLevel")
COMPREPLY=($(compgen -W "${logLevels}" -- ${cur}))
return 0
;;
"--socketFile")
COMPREPLY=($(compgen -f ${cur}))
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
}
complete -F _dcd_server "dcd-server"