Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: west: commands: completion: zsh: add "west shields" completion #87582

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
hlord2000 committed Mar 24, 2025
commit 01efbdc36d6874bc29bde0e5481f9cf9ec83f344
24 changes: 24 additions & 0 deletions scripts/west_commands/completion/west-completion.zsh
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ _west_cmds() {
local -a zephyr_ext_cmds=(
'completion[display shell completion scripts]'
'boards[display information about supported boards]'
'shields[display information about supported shields]'
'build[compile a Zephyr application]'
'sign[sign a Zephyr binary for bootloader chain-loading]'
'flash[flash and run a binary on a board]'
@@ -114,6 +115,18 @@ _get_west_boards() {
_describe 'boards' _west_boards
}

_get_west_shields() {
_west_shields=( $(__west_x shields --format='{name}') )
for i in {1..${#_west_shields[@]}}; do
local name="${_west_shields[$i]%%|*}"
local transformed_shield="${_west_shields[$i]//|//}"
_west_shields[$i]="${transformed_shield//,/ ${name}/}"
done
_west_shields=(${(@s/ /)_west_shields})

_describe 'shields' _west_shields
}

_west_init() {
local -a opts=(
'(-l --local)'{--mr,--manifest-rev}'[manifest revision]:manifest rev:'
@@ -228,6 +241,16 @@ _west_boards() {
_arguments -S $opts
}

_west_shields() {
local -a opts=(
{-f,--format}'[format string]:format string:'
{-n,--name}'[name regex]:regex:'
'*--board-root[Add a board root]:board root:_directories'
)

_arguments -S $opts
}

_west_build() {
local -a opts=(
'(-b --board)'{-b,--board}'[board to build for]:board:_get_west_boards'
@@ -243,6 +266,7 @@ _west_build() {
{-o,--build-opt}'[options to pass to build tool (make or ninja)]:tool opt:'
'(-n --just-print --dry-run --recon)'{-n,--just-print,--dry-run,--recon}"[just print build commands, don't run them]"
'(-p --pristine)'{-p,--pristine}'[pristine build setting]:pristine:(auto always never)'
'--shield[shield to build for]:shield:_get_west_shields'
)
_arguments -S $opts \
"1:source_dir:_directories"