diff --git a/dev-python/typer/typer-0.12.1.ebuild b/dev-python/typer/typer-0.12.1.ebuild index cec0932..76b5955 100644 --- a/dev-python/typer/typer-0.12.1.ebuild +++ b/dev-python/typer/typer-0.12.1.ebuild @@ -39,8 +39,6 @@ RDEPEND=" ') " -COMPLETIONSDIR="${WORKDIR}/comp" - distutils_enable_tests pytest src_test() { @@ -50,24 +48,43 @@ src_test() { distutils-r1_src_test "${@}" } -typer_gen_comp() { - 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_compile() { distutils-r1_src_compile "${@}" - mkdir "${COMPLETIONSDIR}" + local shell + for shell in bash zsh fish; do + typer_gencomp ${shell} + done +} - _TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION=1 typer_gen_comp +typer_get_comp() { + local COMPLETIONSDIR="${WORKDIR}/comp" + local shell="$1" + + case "${shell}" in + bash) echo "${COMPLETIONSDIR}/${PN}" ;; + zsh) echo "${COMPLETIONSDIR}/_${PN}" ;; + fish) echo "${COMPLETIONSDIR}/${PN}.fish" ;; + *) die "unknown shell: ${shell}" ;; + esac +} + +typer_gencomp() { + local COMPLETIONSDIR="${WORKDIR}/comp" + mkdir "${COMPLETIONSDIR}" 2> /dev/null + local shell="$1" + + compfile="$(typer_get_comp "${@}")" + + _TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION=1 python -m typer --show-completion "${shell}" | + sed 's/python -m //g ; s/_PYTHON _M //g' > "${compfile}" || + die "failed to generate ${shell} completion" } src_install() { distutils-r1_src_install "${@}" - dobashcomp "${COMPLETIONSDIR}/${PN}" - dozshcomp "${COMPLETIONSDIR}/_${PN}" - dofishcomp "${COMPLETIONSDIR}/${PN}.fish" + dobashcomp "$(typer_get_comp bash)" + dozshcomp "$(typer_get_comp zsh)" + dofishcomp "$(typer_get_comp fish)" }