Tools: completion: get boards list from help

This commit is contained in:
Pierre Kancir 2019-11-14 14:27:04 +01:00 committed by Peter Barker
parent a415423975
commit 989653bf69
2 changed files with 9 additions and 17 deletions

View File

@ -51,14 +51,14 @@ _waf()
fi
done
# TODO: generate for waf help
case $prev in
--board)
opts="CubeBlack bbbmini fmuv2 fmuv3 fmuv4 iomcu sitl"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
esac
--board)
# get options between board and debug, remove everything before "are", remove everything after "--debug", remove final dot, remove all comma
opts=$(./waf --help | sed -n '/--board=/,/--debug/p' | sed -e 's/.*are //g' -e 's/\(--debug.*\)//g' -e 's/[.]//g' -e 's/[,]//g')
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}

View File

@ -37,18 +37,10 @@ _waf() {
esac
}
# TODO : generate with regex from waf help
(( $+functions[_waf_boards] )) ||
_waf_boards() {
local boards; boards=(
'CubeBlack:builds CubeBlack' \
'bbbmini:build bbbmini' \
'fmuv2:build fmuv2' \
'fmuv3:build fmuv3' \
'fmuv4:build fmuv4' \
'iomcu:build iomcu' \
'sitl:build sitl'
)
# get option between board and debug, remove everything before "are", remove everything after "--debug", remove final dot, remove all comma
local boards; boards=( $(./waf --help | sed -n '/--board=/,/--debug/p' | sed -e 's/.*are //g' -e 's/\(--debug.*\)//g' -e 's/[.]//g' -e 's/[,]//g') )
_describe -t boards 'board' boards "$@" && ret=0
}