From 5f033a551a54cd6040ad638357746c28a15e0b0a Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Wed, 30 Dec 2020 10:25:04 +0100 Subject: [PATCH] Tools: completion: add --target completion --- Tools/completion/zsh/_waf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tools/completion/zsh/_waf b/Tools/completion/zsh/_waf index f0f167845a..d72ae7c778 100644 --- a/Tools/completion/zsh/_waf +++ b/Tools/completion/zsh/_waf @@ -31,6 +31,7 @@ _waf() { '--sitl-flash-storage[Building SITL with flash storage emulation.]' \ '--upload[Upload applicable targets to a connected device]' \ '--board[Board name]:board:_waf_boards' \ + '--target=[Target name]:target:_waf_targets' \ '*:: :->args' \ && ret=0 ;; @@ -43,6 +44,13 @@ _waf_boards() { _describe -t boards 'board' boards "$@" && ret=0 } +(( $+functions[_waf_targets] )) || +_waf_targets() { + # list target without color, remove Lua embedding, remove empty and space only line, remove objs/*, remove path for lua binding, remove trailing spaces, change line return for space + local targets; targets=( $(./waf list -c no | sed -e '/^Embedding/d' -e '/^ *$/d' -e '/objs\//d' -e '$d' -e '/^\//d' | tr -d " " | tr '\n' ' ')) + _describe -t targets 'target' targets "$@" && ret=0 +} + # TODO generate with regex from waf help (( $+functions[_waf_cmds] )) || _waf_cmds() {