summaryrefslogtreecommitdiff
path: root/Auxiliary
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-05-01 07:14:33 +0000
committerKitware Robot <kwrobot@kitware.com>2022-05-01 03:14:47 -0400
commitc33c389f71cae440af7482b3faf678df58bc4943 (patch)
tree31999596f362204d94e5eb809fd6044b26e3fd44 /Auxiliary
parent5327176fc26756814c4776cf0e08650add0b5417 (diff)
parentf7a6e036ade1bce40e10a2575f4c677af5832a79 (diff)
downloadcmake-c33c389f71cae440af7482b3faf678df58bc4943.tar.gz
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/cmake38
-rw-r--r--Auxiliary/bash-completion/ctest11
2 files changed, 48 insertions, 1 deletions
diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake
index d8d2c86b0c..bed7248f70 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 49343bb9d6..3c629d2036 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