aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-09-23 12:24:19 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-09-23 12:24:19 -0700
commit9f893384db123567087d5cb5f5016df571512b38 (patch)
tree23912d2325a0a4fd33ce9edfb73f8859e02da4c5 /data
parent3afaa879ecea489d4bb9bd0b563a2fafd594a051 (diff)
downloadmeson-9f893384db123567087d5cb5f5016df571512b38.zip
meson-9f893384db123567087d5cb5f5016df571512b38.tar.gz
meson-9f893384db123567087d5cb5f5016df571512b38.tar.bz2
zsh: add completions for subprojects
Diffstat (limited to 'data')
-rw-r--r--data/shell-completions/zsh/_meson80
1 files changed, 77 insertions, 3 deletions
diff --git a/data/shell-completions/zsh/_meson b/data/shell-completions/zsh/_meson
index 80dc6f6..74dfca4 100644
--- a/data/shell-completions/zsh/_meson
+++ b/data/shell-completions/zsh/_meson
@@ -79,6 +79,7 @@ local -a meson_commands=(
'setup:set up a build directory'
'test:run tests'
'wrap:manage source dependencies'
+'subprojects:manage subprojects'
)
(( $+functions[__meson_is_build_dir] )) || __meson_is_build_dir() {
@@ -116,8 +117,8 @@ local -a meson_commands=(
}
(( $+functions[__meson_installed_wraps] )) || __meson_installed_wraps() {
- if [[ -d "subprojects" ]]; then
- local rwraps="$(ls subprojects/ | grep '\.wrap$' | cut -d . -f 1)"
+ local rwraps
+ if rwraps="$(ls subprojects/ | grep '\.wrap$' | cut -d . -f 1)"; then
local -a wraps=(${(@f)rwraps})
_describe -t wraps "Meson wraps" wraps
fi
@@ -265,7 +266,7 @@ _arguments \
)
if (( CURRENT == 2 )); then
- _describe -t commands "Meson subcommands" commands
+ _describe -t commands "Meson wrap subcommands" commands
else
local curcontext="$curcontext"
cmd="${${commands[(r)$words[2]:*]%%:*}}"
@@ -309,6 +310,79 @@ _arguments \
"${(@)specs}"
}
+(( $+functions[_meson-subprojects-update] )) || _meson-subprojects-update() {
+ local curcontext="$curcontext"
+ local -a specs=(
+ "--rebase[rebase your branch on top of wrap's revision (git only)]"
+ '--sourcedir=[path to source directory]:_directories'
+ '*:subprojects:__meson_installed_wraps'
+ )
+_arguments \
+ '(: -)'{'--help','-h'}'[show a help message and quit]' \
+ "${(@)specs}"
+}
+
+(( $+functions[_meson-subprojects-checkout] )) || _meson-subprojects-checkout() {
+ local curcontext="$curcontext"
+ local -a specs=(
+ '-b[create a new branch]'
+ '--sourcedir=[path to source directory]:_directories'
+ # FIXME: this doesn't work exactly right, but I can't figure it out
+ ':branch name'
+ '*:subprojects:__meson_installed_wraps'
+ )
+_arguments \
+ '(: -)'{'--help','-h'}'[show a help message and quit]' \
+ "${(@)specs}"
+}
+
+(( $+functions[_meson-subprojects-download] )) || _meson-subprojects-download() {
+ local curcontext="$curcontext"
+ local -a specs=(
+ '--sourcedir=[path to source directory]:_directories'
+ )
+_arguments \
+ '(: -)'{'--help','-h'}'[show a help message and quit]' \
+ "${(@)specs}"
+}
+
+(( $+functions[_meson-subprojects-foreach] )) || _meson-subprojects-foreach() {
+ local curcontext="$curcontext"
+ local -a specs=(
+ '--sourcedir=[path to source directory]:_directories'
+ '*:command:_command_names -e'
+ )
+_arguments \
+ '(: -)'{'--help','-h'}'[show a help message and quit]' \
+ "${(@)specs}"
+}
+
+(( $+functions[_meson-subprojects] )) || _meson-subprojects() {
+ local -a commands=(
+ 'update:update all subprojects from wrap files'
+ 'checkout:checkout a branch (git only)'
+ 'download:ensure subprojects are fetched, even if not in use. Already downloaded subprojects are not modified.'
+ 'foreach:execute a command in each subproject directory'
+ )
+
+ if (( CURRENT == 2 )); then
+ _describe -t commands "Meson subproject subcommands" commands
+ else
+ local curcontext="$curcontext"
+ cmd="${${commands[(r)$words[2]:*]%%:*}}"
+ if (( $#cmd )); then
+ if [[ $cmd == status ]]; then
+ _message "no options"
+ else
+ _meson-subprojects-$cmd
+ fi
+ else
+ _message "unknown meson subproject command: $words[2]"
+ fi
+ fi
+
+}
+
if [[ $service != meson ]]; then
_call_function ret _$service