@@ -25,6 +25,7 @@ _west_cmds() {
2525 local -a zephyr_ext_cmds=(
2626 ' completion[display shell completion scripts]'
2727 ' boards[display information about supported boards]'
28+ ' shields[display information about supported shields]'
2829 ' build[compile a Zephyr application]'
2930 ' sign[sign a Zephyr binary for bootloader chain-loading]'
3031 ' flash[flash and run a binary on a board]'
@@ -114,6 +115,18 @@ _get_west_boards() {
114115 _describe ' boards' _west_boards
115116}
116117
118+ _get_west_shields () {
119+ _west_shields=( $( __west_x shields --format=' {name}' ) )
120+ for i in {1..${# _west_shields[@]} }; do
121+ local name=" ${_west_shields[$i]%% |* } "
122+ local transformed_shield=" ${_west_shields[$i]// |// } "
123+ _west_shields[$i ]=" ${transformed_shield// ,/ ${name} / } "
124+ done
125+ _west_shields=(${(@ s/ / )_west_shields} )
126+
127+ _describe ' shields' _west_shields
128+ }
129+
117130_west_init () {
118131 local -a opts=(
119132 ' (-l --local)' {--mr,--manifest-rev}' [manifest revision]:manifest rev:'
@@ -228,6 +241,16 @@ _west_boards() {
228241 _arguments -S $opts
229242}
230243
244+ _west_shields () {
245+ local -a opts=(
246+ {-f,--format}' [format string]:format string:'
247+ {-n,--name}' [name regex]:regex:'
248+ ' *--board-root[Add a board root]:board root:_directories'
249+ )
250+
251+ _arguments -S $opts
252+ }
253+
231254_west_build () {
232255 local -a opts=(
233256 ' (-b --board)' {-b,--board}' [board to build for]:board:_get_west_boards'
@@ -243,6 +266,7 @@ _west_build() {
243266 {-o,--build-opt}' [options to pass to build tool (make or ninja)]:tool opt:'
244267 ' (-n --just-print --dry-run --recon)' {-n,--just-print,--dry-run,--recon}" [just print build commands, don't run them]"
245268 ' (-p --pristine)' {-p,--pristine}' [pristine build setting]:pristine:(auto always never)'
269+ ' --shield[shield to build for]:shield:_get_west_shields'
246270 )
247271 _arguments -S $opts \
248272 " 1:source_dir:_directories"
0 commit comments