diff options
author | Craig Scott <craig.scott@crascit.com> | 2022-05-01 07:14:33 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-05-01 07:14:47 (GMT) |
commit | c33c389f71cae440af7482b3faf678df58bc4943 (patch) | |
tree | 31999596f362204d94e5eb809fd6044b26e3fd44 /Auxiliary | |
parent | 5327176fc26756814c4776cf0e08650add0b5417 (diff) | |
parent | f7a6e036ade1bce40e10a2575f4c677af5832a79 (diff) | |
download | CMake-c33c389f71cae440af7482b3faf678df58bc4943.zip CMake-c33c389f71cae440af7482b3faf678df58bc4943.tar.gz CMake-c33c389f71cae440af7482b3faf678df58bc4943.tar.bz2 |
Merge topic 'preset-bash-completion'
f7a6e036ad bash-completion: Support CMakePresets in cmake and ctest completion
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Craig Scott <craig.scott@crascit.com>
Merge-request: !7148
Diffstat (limited to 'Auxiliary')
-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 |