aboutsummaryrefslogtreecommitdiffstats
path: root/src/_cmake
diff options
context:
space:
mode:
authorHuw Percival <huw.percival@dyson.com>2022-02-23 10:40:29 +0000
committerHuw Percival <huw.percival@dyson.com>2022-02-23 10:40:29 +0000
commitff6031a8ea549ca8deff1f163a43388cce936160 (patch)
tree558514aea2bd2ddbb11ccec7efa3b51ced41a3b7 /src/_cmake
parentfix presets (diff)
downloadzsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.tar
zsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.tar.gz
zsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.tar.bz2
zsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.tar.lz
zsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.tar.xz
zsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.tar.zst
zsh-completions-ff6031a8ea549ca8deff1f163a43388cce936160.zip
re-write to use python, hopefully this is portable enough, tested with python 3.6.5 anf 2.7.18
Diffstat (limited to 'src/_cmake')
-rw-r--r--src/_cmake16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/_cmake b/src/_cmake
index cc5de89..20b88ac 100644
--- a/src/_cmake
+++ b/src/_cmake
@@ -141,13 +141,21 @@ _cmake_generator_options() {
# --------------
(( $+functions[_cmake_presets] )) ||
_cmake_presets() {
- local invoke; invoke=(${words[@]})
- # TODO: remove all arguments -* except -S
- invoke[$CURRENT]=--list-presets
+
+ local parse_presets; parse_presets='
+import json
+import os
+try:
+ with open("CMakePresets.json") as preset_file:
+ print(os.linesep.join([ x["name"] + ":" + x.get("description", "") for x in json.load(preset_file)["configurePresets"]]))
+except:
+ pass
+
+'
# TODO: Problems with quotes need eval
# would need a way to exec the array
- local list_presets; list_presets=(${(f)"$(eval "${invoke[@]} 2> /dev/null" | grep -Po '(?<=\").*(?=")' )"})
+ local list_presets; list_presets=(${(f)"$(eval python <<< $parse_presets)"})
_describe 'presets' list_presets
}