aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Beguin <liambeguin@gmail.com>2022-09-05 12:39:43 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-09-18 15:22:48 -0400
commit3f86f19f95d36f2e489a25e1996ab2e2d43079ae (patch)
treee2a81db4f95e5e005dac7be972e8e1caf81c4f44
parent24e97e19457281caebd3584f2913bd514ad01d60 (diff)
downloadmeson-3f86f19f95d36f2e489a25e1996ab2e2d43079ae.zip
meson-3f86f19f95d36f2e489a25e1996ab2e2d43079ae.tar.gz
meson-3f86f19f95d36f2e489a25e1996ab2e2d43079ae.tar.bz2
completions: bash: define sub-commands as an array
Define subcommands as an array so that they can be reused for the top-level sub-command completion. Signed-off-by: Liam Beguin <liambeguin@gmail.com>
-rw-r--r--data/shell-completions/bash/meson41
1 files changed, 21 insertions, 20 deletions
diff --git a/data/shell-completions/bash/meson b/data/shell-completions/bash/meson
index b4bdb43..9004981 100644
--- a/data/shell-completions/bash/meson
+++ b/data/shell-completions/bash/meson
@@ -1,26 +1,27 @@
_meson() {
command="${COMP_WORDS[1]}"
- case "$command" in
- setup |\
- configure |\
- dist | \
- install |\
- introspect |\
- init |\
- test |\
- wrap |\
- subprojects |\
- help |\
- rewrite |\
- compile |\
- devenv |\
- env2mfile)
+ meson_subcommands=(
+ setup
+ configure
+ dist
+ install
+ introspect
+ init
+ test
+ wrap
+ subprojects
+ help
+ rewrite
+ compile
+ devenv
+ env2mfile
+ )
+
+ if [[ " ${meson_subcommands[*]} " =~ " ${command} " ]]; then
_meson-$command "${COMP_WORDS[@]:1}"
- ;;
- *)
+ else
_meson-setup "${COMP_WORDS[@]}"
- ;;
- esac
+ fi
} &&
complete -F _meson meson
@@ -197,7 +198,7 @@ _meson-setup() {
fi
if [ $COMP_CWORD -eq 1 ]; then
- COMPREPLY+=($(compgen -W 'setup configure test introspect' -- "$cur"))
+ COMPREPLY+=($(compgen -W "${meson_subcommands[*]}" -- "$cur"))
fi
fi
}