diff options
author | Christopher Arndt | 2022-10-13 19:18:40 +0200 |
---|---|---|
committer | Christopher Arndt | 2022-10-13 19:18:40 +0200 |
commit | e2a8a9fbb0103a722f64581c049ff757624341ef (patch) | |
tree | 4061618388194bab15cd8da5cb1ad0e87c5f85c1 | |
parent | d39d38b487faea31adcead4d0bcf91ff4e59563a (diff) | |
download | aur-e2a8a9fbb0103a722f64581c049ff757624341ef.tar.gz |
feat: add Bash, Zsh and Fish completion config
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 22 | ||||
-rw-r--r-- | pip-tools-bash-completion.sh | 57 | ||||
-rw-r--r-- | pip-tools-fish-completion.fish | 43 | ||||
-rw-r--r-- | pip-tools-zsh-completion.zsh | 69 |
5 files changed, 195 insertions, 4 deletions
@@ -1,7 +1,7 @@ pkgbase = pip-tools pkgdesc = A set of tools to keep your pinned Python dependencies fresh pkgver = 6.9.0 - pkgrel = 1 + pkgrel = 2 url = https://github.com/jazzband/pip-tools/ arch = any license = BSD @@ -15,6 +15,12 @@ pkgbase = pip-tools depends = python-setuptools depends = python-wheel source = https://files.pythonhosted.org/packages/source/p/pip-tools/pip-tools-6.9.0.tar.gz + source = pip-tools-bash-completion.sh + source = pip-tools-zsh-completion.zsh + source = pip-tools-fish-completion.fish sha256sums = b4762359978fd81a2b4b666e6dca15266bdc65680d06900c4da34243f35e4b5d + sha256sums = 12d90c4aab717d58a435610a3cdc94aa925b4f89f9f9f700a05c8cfa058f7960 + sha256sums = 63f8d032a742ae33903040477c777922ec06241383d165c93803f1b41316ff51 + sha256sums = 9c60407e485e71ded1d695455378fa4f09e76ecb8556d21c31f8610cb47cf525 pkgname = pip-tools @@ -3,15 +3,21 @@ pkgname=pip-tools pkgver=6.9.0 -pkgrel=1 +pkgrel=2 pkgdesc='A set of tools to keep your pinned Python dependencies fresh' arch=(any) url='https://github.com/jazzband/pip-tools/' license=(BSD) depends=('python-click>=7' python-build 'python-pip>=21' python-setuptools python-wheel) makedepends=(python-build python-installer python-setuptools-scm python-wheel) -source=("https://files.pythonhosted.org/packages/source/${pkgname::1}/${pkgname}/${pkgname}-${pkgver}.tar.gz") -sha256sums=('b4762359978fd81a2b4b666e6dca15266bdc65680d06900c4da34243f35e4b5d') +source=("https://files.pythonhosted.org/packages/source/${pkgname::1}/${pkgname}/${pkgname}-${pkgver}.tar.gz" + 'pip-tools-bash-completion.sh' + 'pip-tools-zsh-completion.zsh' + 'pip-tools-fish-completion.fish') +sha256sums=('b4762359978fd81a2b4b666e6dca15266bdc65680d06900c4da34243f35e4b5d' + '12d90c4aab717d58a435610a3cdc94aa925b4f89f9f9f700a05c8cfa058f7960' + '63f8d032a742ae33903040477c777922ec06241383d165c93803f1b41316ff51' + '9c60407e485e71ded1d695455378fa4f09e76ecb8556d21c31f8610cb47cf525') build() { @@ -22,6 +28,10 @@ build() { package() { cd $pkgname-$pkgver python -m installer --destdir="$pkgdir" dist/*.whl + # shell completion + install -Dm644 "$srcdir"/pip-tools-bash-completion.sh "$pkgdir"/etc/bash_completion.d/pip-tools + install -Dm644 "$srcdir"/pip-tools-zsh-completion.zsh "$pkgdir"/usr/share/zsh/site-functions/_pip-tools + install -Dm644 "$srcdir"/pip-tools-fish-completion.fish "$pkgdir"/usr/share/fish/vendor_completions.d/pip-tools.fish # license install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname # documentation @@ -29,6 +39,12 @@ package() { -t "$pkgdir/usr/share/doc/$pkgname" install -Dm644 img/*.svg -t "$pkgdir"/usr/share/doc/$pkgname/img install -Dm644 examples/* -t "$pkgdir"/usr/share/doc/$pkgname/examples + + # Suppress warnings from deprecated Python distutils package + sed -i -e 's@python$@python -W ignore:Setuptools is replacing distutils.:UserWarning:@' \ + "$pkgdir"/usr/bin/pip-compile + sed -i -e 's@python$@python -W ignore:Setuptools is replacing distutils.:UserWarning:@' \ + "$pkgdir"/usr/bin/pip-sync } # vim:set ts=2 sw=2 et: diff --git a/pip-tools-bash-completion.sh b/pip-tools-bash-completion.sh new file mode 100644 index 000000000000..8e6a9acaed58 --- /dev/null +++ b/pip-tools-bash-completion.sh @@ -0,0 +1,57 @@ +_pip_sync_completion() { + local IFS=$'\n' + local response + + response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _PIP_SYNC_COMPLETE=bash_complete $1) + + for completion in $response; do + IFS=',' read type value <<< "$completion" + + if [[ $type == 'dir' ]]; then + COMPREPLY=() + compopt -o dirnames + elif [[ $type == 'file' ]]; then + COMPREPLY=() + compopt -o default + elif [[ $type == 'plain' ]]; then + COMPREPLY+=($value) + fi + done + + return 0 +} + +_pip_sync_completion_setup() { + complete -o nosort -F _pip_sync_completion pip-sync +} + +_pip_sync_completion_setup + +_pip_compile_completion() { + local IFS=$'\n' + local response + + response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _PIP_COMPILE_COMPLETE=bash_complete $1) + + for completion in $response; do + IFS=',' read type value <<< "$completion" + + if [[ $type == 'dir' ]]; then + COMPREPLY=() + compopt -o dirnames + elif [[ $type == 'file' ]]; then + COMPREPLY=() + compopt -o default + elif [[ $type == 'plain' ]]; then + COMPREPLY+=($value) + fi + done + + return 0 +} + +_pip_compile_completion_setup() { + complete -o nosort -F _pip_compile_completion pip-compile +} + +_pip_compile_completion_setup; diff --git a/pip-tools-fish-completion.fish b/pip-tools-fish-completion.fish new file mode 100644 index 000000000000..435b19c2656d --- /dev/null +++ b/pip-tools-fish-completion.fish @@ -0,0 +1,43 @@ +function _pip_sync_completion; + set -l response; + + for value in (env _PIP_SYNC_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) pip-sync); + set response $response $value; + end; + + for completion in $response; + set -l metadata (string split "," $completion); + + if test $metadata[1] = "dir"; + __fish_complete_directories $metadata[2]; + else if test $metadata[1] = "file"; + __fish_complete_path $metadata[2]; + else if test $metadata[1] = "plain"; + echo $metadata[2]; + end; + end; +end; + +complete --no-files --command pip-sync --arguments "(_pip_sync_completion)"; + +function _pip_compile_completion; + set -l response; + + for value in (env _PIP_COMPILE_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) pip-compile); + set response $response $value; + end; + + for completion in $response; + set -l metadata (string split "," $completion); + + if test $metadata[1] = "dir"; + __fish_complete_directories $metadata[2]; + else if test $metadata[1] = "file"; + __fish_complete_path $metadata[2]; + else if test $metadata[1] = "plain"; + echo $metadata[2]; + end; + end; +end; + +complete --no-files --command pip-compile --arguments "(_pip_compile_completion)"; diff --git a/pip-tools-zsh-completion.zsh b/pip-tools-zsh-completion.zsh new file mode 100644 index 000000000000..1fd71587266c --- /dev/null +++ b/pip-tools-zsh-completion.zsh @@ -0,0 +1,69 @@ +#compdef pip-sync + +_pip_sync_completion() { + local -a completions + local -a completions_with_descriptions + local -a response + (( ! $+commands[pip-sync] )) && return 1 + + response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _PIP_SYNC_COMPLETE=zsh_complete pip-sync)}") + + for type key descr in ${response}; do + if [[ "$type" == "plain" ]]; then + if [[ "$descr" == "_" ]]; then + completions+=("$key") + else + completions_with_descriptions+=("$key":"$descr") + fi + elif [[ "$type" == "dir" ]]; then + _path_files -/ + elif [[ "$type" == "file" ]]; then + _path_files -f + fi + done + + if [ -n "$completions_with_descriptions" ]; then + _describe -V unsorted completions_with_descriptions -U + fi + + if [ -n "$completions" ]; then + compadd -U -V unsorted -a completions + fi +} + +compdef _pip_sync_completion pip-sync + +#compdef pip-compile + +_pip_compile_completion() { + local -a completions + local -a completions_with_descriptions + local -a response + (( ! $+commands[pip-compile] )) && return 1 + + response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _PIP_COMPILE_COMPLETE=zsh_complete pip-compile)}") + + for type key descr in ${response}; do + if [[ "$type" == "plain" ]]; then + if [[ "$descr" == "_" ]]; then + completions+=("$key") + else + completions_with_descriptions+=("$key":"$descr") + fi + elif [[ "$type" == "dir" ]]; then + _path_files -/ + elif [[ "$type" == "file" ]]; then + _path_files -f + fi + done + + if [ -n "$completions_with_descriptions" ]; then + _describe -V unsorted completions_with_descriptions -U + fi + + if [ -n "$completions" ]; then + compadd -U -V unsorted -a completions + fi +} + +compdef _pip_compile_completion pip-compile; |