diff options
-rw-r--r-- | Auxiliary/bash-completion/cmake | 38 | ||||
-rw-r--r-- | Auxiliary/bash-completion/ctest | 11 |
2 files changed, 48 insertions, 1 deletions
diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake index d8d2c86..bed7248 100644 --- a/Auxiliary/bash-completion/cmake +++ b/Auxiliary/bash-completion/cmake @@ -96,7 +96,15 @@ _cmake() _filedir return ;; - --build|--install|--open) + --build) + # Seed the reply with non-directory arguments that we know are + # allowed to follow --build. _filedir will then prepend any valid + # directory matches to these. + COMPREPLY=( $( compgen -W "--preset --list-presets" -- "$cur" ) ) + _filedir -d + return + ;; + --install|--open) _filedir -d return ;; @@ -149,6 +157,34 @@ _cmake() 2>/dev/null | grep -v "^cmake version " )' -- "$cur" ) ) return ;; + --list-presets) + local IFS=$'\n' + local quoted + printf -v quoted %q "$cur" + + if [[ ! "${IFS}${COMP_WORDS[*]}${IFS}" =~ "${IFS}--build${IFS}" ]]; then + COMPREPLY=( $( compgen -W "configure${IFS}build${IFS}test${IFS}all" -- "$quoted" ) ) + fi + return + ;; + --preset) + local IFS=$'\n' + local quoted + printf -v quoted %q "$cur" + + local build_or_configure="configure" + if [[ "${IFS}${COMP_WORDS[*]}${IFS}" =~ "${IFS}--build${IFS}" ]]; then + build_or_configure="build" + fi + + local presets=$( cmake --list-presets="$build_or_configure" 2>/dev/null | + grep -o "^ \".*\"" | sed \ + -e "s/^ //g" \ + -e "s/\"//g" \ + -e 's/ /\\\\ /g' ) + COMPREPLY=( $( compgen -W "$presets" -- "$quoted" ) ) + return + ;; esac $split && return diff --git a/Auxiliary/bash-completion/ctest b/Auxiliary/bash-completion/ctest index 49343bb..3c629d2 100644 --- a/Auxiliary/bash-completion/ctest +++ b/Auxiliary/bash-completion/ctest @@ -103,6 +103,17 @@ _ctest() 2>/dev/null | grep -v "^ctest version " )' -- "$cur" ) ) return ;; + --preset) + local IFS=$'\n' + local quoted + printf -v quoted %q "$cur" + COMPREPLY=( $( compgen -W '$( ctest --list-presets 2>/dev/null | + grep -o "^ \".*\"" | sed \ + -e "s/^ //g" \ + -e "s/\"//g" \ + -e "s/ /\\\\ /g" )' -- "$quoted" ) ) + return + ;; esac if [[ "$cur" == -* ]]; then |