summaryrefslogtreecommitdiffstats
path: root/Auxiliary
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-05-01 07:14:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-05-01 07:14:47 (GMT)
commitc33c389f71cae440af7482b3faf678df58bc4943 (patch)
tree31999596f362204d94e5eb809fd6044b26e3fd44 /Auxiliary
parent5327176fc26756814c4776cf0e08650add0b5417 (diff)
parentf7a6e036ade1bce40e10a2575f4c677af5832a79 (diff)
downloadCMake-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/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 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