diff --git a/PKGBUILD b/PKGBUILD index 6948814..91b375e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,14 +1,25 @@ # PKGBUILD pkgname=comp -pkgver=1.0 -pkgrel=1 +pkgver=1.2 +pkgrel=5 pkgdesc="Simple folder compression with pv and pigz" arch=('any') license=('MIT') -deps=('tar' 'pv' 'pigz') -source=('comp.sh') -md5sums=('SKIP') +deps=('tar>0.0.0' 'pv>0.0.0' 'pigz>0.0.0') +source=('comp.sh' 'comp.bash' '_comp') +sha256sums=('18752ab3436748a777b2b384fdd8b5dc1fd69d81fe73c7f0482d8d633e1509e5' + 'e90c5e24ad932296b932a8dd0cfcc42051209a755828408229d73c2dc6321e83' + '8ed621a9435b3f6d066abde2fb7eae964dda82ab90824b7fc07d167834863633') + + +prepare() { + sed -i "s/__VERSION__/$pkgver/" "$srcdir/comp.sh" +} package() { install -Dm755 "$srcdir/comp.sh" "$pkgdir/usr/bin/comp" + + install -Dm644 "$srcdir/comp.bash" "$pkgdir/usr/share/bash-completion/completions/comp" + + install -Dm644 "$srcdir/_comp" "$pkgdir/usr/share/zsh/site-functions/_comp" } diff --git a/_comp b/_comp new file mode 100644 index 0000000..6cae096 --- /dev/null +++ b/_comp @@ -0,0 +1,19 @@ +#compdef comp + +_comp() { + _arguments \ + '-h[Prints help message]' \ + '--help[Prints help message]' \ + '-v[Print version]' \ + '--version[Print version]' \ + '1:file or folder to compress:_files_or_dirs' \ + '2:output file:_files' + + # Custom function to complete both files and directories + _files_or_dirs() { + _alternative \ + 'directories:: _directories' \ + 'files:: _files' + } + +} diff --git a/comp-1.0-1-any.pkg.tar.zst b/comp-1.0-1-any.pkg.tar.zst new file mode 100644 index 0000000..8e554c1 Binary files /dev/null and b/comp-1.0-1-any.pkg.tar.zst differ diff --git a/comp-1.1-1-any.pkg.tar.zst b/comp-1.1-1-any.pkg.tar.zst new file mode 100644 index 0000000..a942f76 Binary files /dev/null and b/comp-1.1-1-any.pkg.tar.zst differ diff --git a/comp-1.2-1-any.pkg.tar.zst b/comp-1.2-1-any.pkg.tar.zst new file mode 100644 index 0000000..256ecc4 Binary files /dev/null and b/comp-1.2-1-any.pkg.tar.zst differ diff --git a/comp-1.2-2-any.pkg.tar.zst b/comp-1.2-2-any.pkg.tar.zst new file mode 100644 index 0000000..0a37452 Binary files /dev/null and b/comp-1.2-2-any.pkg.tar.zst differ diff --git a/comp-1.2-3-any.pkg.tar.zst b/comp-1.2-3-any.pkg.tar.zst new file mode 100644 index 0000000..d866f30 Binary files /dev/null and b/comp-1.2-3-any.pkg.tar.zst differ diff --git a/comp-1.2-4-any.pkg.tar.zst b/comp-1.2-4-any.pkg.tar.zst new file mode 100644 index 0000000..14a351f Binary files /dev/null and b/comp-1.2-4-any.pkg.tar.zst differ diff --git a/comp.bash b/comp.bash new file mode 100644 index 0000000..6b970f6 --- /dev/null +++ b/comp.bash @@ -0,0 +1,23 @@ +# completions/comp.bash +_comp_completions() +{ + local cur prev opts + COMPREPLY=() + cur = "${COMP_WORDS[COMP_CWORD]}" + prev = "${COMP_WORDS[COMP_CWORD-1]}" + opts = "-h --help -v --version" + + if [[ "$cur" == -* ]]; then + COMPREPLY = ( $(compgen -W "${opts}" -- "$cur")) + return 0 + fi + + if [[ $COMP_CWORD -eq 1 ]]; then + COMPREPLY=( $(compgen -d -- "$cur") $(compgen -f -- "$cur")) + return 0 + fi + + return 0 +} + +complete -F _comp_completions comp diff --git a/comp.sh b/comp.sh old mode 100644 new mode 100755 index dee8af7..0297c2a --- a/comp.sh +++ b/comp.sh @@ -3,8 +3,30 @@ # Usage: comp [output_fildename] # Check if input folder is provided + +VERSION="__VERSION__" + if [[ -z "$1" ]]; then - echo "Usage: comp [output_filename]" + echo "Usage: comp [output_file]" + echo "comp " + exit 1 + elif [[ "$1" == "-h" || "$1" == "--help" ]]; then + echo "Usage:" + echo " comp [output_file]" + echo " comp