Tools: completion: add --target completion

This commit is contained in:
Pierre Kancir 2020-12-30 10:25:04 +01:00 committed by Peter Barker
parent 7f999ef64a
commit 5f033a551a

View File

@ -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() {