Enhance bash completion file for cmake and ctest

- filter out cmake/ctest version line
- provide -R as -E completion with ctest
This commit is contained in:
Eric NOULARD 2012-01-03 18:12:56 +01:00
parent df224727cf
commit 4d253d1a9d
1 changed files with 16 additions and 9 deletions

View File

@ -51,13 +51,20 @@ _cmake()
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
;; ;;
# FIXME: don't know how to handle multi words completion
# or more precisely word that contains space in them like "Unix Makefiles"
# -G)
# local running=$(for x in `cmake --help | grep "^ .*=\ .*" | grep -v "^ -" | cut -d"=" -f 1 | grep -v "^ "`; do echo \"${x}\" ; done )
# COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
# return 0
# ;;
--help-command) --help-command)
local running=$(for x in `cmake --help-command-list`; do echo ${x} ; done ) local running=$(for x in `cmake --help-command-list | grep -v "cmake version"`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
;; ;;
--help-module) --help-module)
local running=$(for x in `cmake --help-module-list`; do echo ${x} ; done ) local running=$(for x in `cmake --help-module-list | grep -v "cmake version"`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
;; ;;
@ -67,12 +74,12 @@ _cmake()
return 0 return 0
;; ;;
--help-property) --help-property)
local running=$(for x in `cmake --help-property-list`; do echo ${x} ; done ) local running=$(for x in `cmake --help-property-list | grep -v "cmake version"`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
;; ;;
--help-variable) --help-variable)
local running=$(for x in `cmake --help-variable-list`; do echo ${x} ; done ) local running=$(for x in `cmake --help-variable-list | grep -v "cmake version"`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
;; ;;
@ -128,14 +135,14 @@ _cpack()
esac esac
# #
# Complete the option (Level 0 - right after cmake) # Complete the option (Level 0 - right after cpack)
# #
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
} && } &&
complete -F _cpack -o default cpack complete -F _cpack -o default cpack
# #
# cmake command # ctest command
# #
# have ctest && # have ctest &&
_ctest() _ctest()
@ -156,11 +163,11 @@ _ctest()
# #
case "${prev}" in case "${prev}" in
--help-command) --help-command)
local running=$(for x in `ctest --help-command-list`; do echo ${x} ; done ) local running=$(for x in `ctest --help-command-list | grep -v "ctest version" `; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
;; ;;
-R) -R|-E)
local running=$(for x in `ctest -N 2> /dev/null | grep "^ Test" | cut -d: -f 2`; do echo ${x} ; done ) local running=$(for x in `ctest -N 2> /dev/null | grep "^ Test" | cut -d: -f 2`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0 return 0
@ -187,4 +194,4 @@ complete -F _ctest -o default ctest
# sh-indent-comment: t # sh-indent-comment: t
# indent-tabs-mode: nil # indent-tabs-mode: nil
# End: # End:
# ex: ts=4 sw=4 et filetype=sh # ex: ts=4 sw=4 et filetype=sh