Skip to content

Commit 1b6feab

Browse files
hlord2000kartben
authored andcommitted
scripts: west: commands: completion: zsh: add "west shields" completion
Adds west shields completion to zsh, matching funtionality found in bash autocomplete. Signed-off-by: Helmut Lord <kellyhlord@gmail.com>
1 parent 4eec258 commit 1b6feab

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/west_commands/completion/west-completion.zsh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)