dev-python/typer: generate shell completions in src_compile

This commit is contained in:
odrling 2024-04-05 21:49:08 +02:00
parent 91aa52ab55
commit 081756569b
No known key found for this signature in database
GPG key ID: EC907F69A27A90C5

View file

@ -36,6 +36,8 @@ RDEPEND="
')
"
COMPLETIONSDIR="${WORKDIR}/comp"
distutils_enable_tests pytest
src_test() {
@ -45,11 +47,22 @@ src_test() {
distutils-r1_src_test "${@}"
}
src_compile() {
distutils-r1_src_compile "${@}"
mkdir "${COMPLETIONSDIR}"
export _TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION=1
python -m typer --show-completion bash > "${COMPLETIONSDIR}/${PN}"
python -m typer --show-completion zsh > "${COMPLETIONSDIR}/_${PN}"
python -m typer --show-completion fish > "${COMPLETIONSDIR}/${PN}.fish"
}
src_install() {
distutils-r1_src_install "${@}"
export _TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION=1
newzshcomp <(python -m typer --show-completion zsh) "_${PN}"
newfishcomp <(python -m typer --show-completion fish) "${PN}.fish"
newbashcomp <(python -m typer --show-completion bash) "${PN}"
dobashcomp "${COMPLETIONSDIR}/${PN}"
dozshcomp "${COMPLETIONSDIR}/_${PN}"
dofishcomp "${COMPLETIONSDIR}/${PN}.fish"
}