mirror of
https://github.com/zsh-users/zsh-completions.git
synced 2026-09-17 16:00:19 +00:00
re-write to use python, hopefully this is portable enough, tested with python 3.6.5 anf 2.7.18
This commit is contained in:
+12
-4
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user