diff options
| author | Huw Percival <huw.percival@dyson.com> | 2022-02-23 10:40:29 +0000 |
|---|---|---|
| committer | Huw Percival <huw.percival@dyson.com> | 2022-02-23 10:40:29 +0000 |
| commit | ff6031a8ea549ca8deff1f163a43388cce936160 (patch) | |
| tree | 558514aea2bd2ddbb11ccec7efa3b51ced41a3b7 /src/_cmake | |
| parent | fix presets (diff) | |
| download | zsh-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/_cmake | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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 } |
