makedeb


una-bin 3.2.0-1


Una is a simple MPR helper.

Click here to go back to the commit logs for una-bin.

Commit:


Hash: cc73e72d4b6c37be05654197fc6635250b61139b

Message: 1.1.0 - add autocompletions

Diff


diff --git a/.SRCINFO b/.SRCINFO
index cc25224..5c63742 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -2,11 +2,12 @@ generated-by = makedeb-makepkg
 
 pkgbase = una-bin
 	pkgdesc = Una is a simple MPR helper.
-	pkgver = 1.0.9
+	pkgver = 1.1.0
 	pkgrel = 1
 	url = https://github.com/AFK-OS/una
 	arch = any
 	depends = bash
+	depends = bash-completion
 	depends = ncurses-bin
 	depends = python3
 	depends = git
@@ -16,8 +17,11 @@ pkgbase = una-bin
 	depends = coreutils
 	depends = sudo
 	depends = jq
+	depends = gzip
 	provides = una
 	source = https://github.com/AFK-OS/una/raw/main/una
+	source = https://github.com/AFK-OS/una/raw/main/una-completion
+	sha256sums = SKIP
 	sha256sums = SKIP
 
 pkgname = una-bin
diff --git a/PKGBUILD b/PKGBUILD
index 2fc1735..f40871b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,16 +1,19 @@
 # Maintainer: Rudra Saraswat <rs2009@ubuntu.com>
 pkgname=una-bin
-pkgver=1.0.9
+pkgver=1.1.0
 pkgrel=1
 url='https://github.com/AFK-OS/una'
 pkgdesc='Una is a simple MPR helper.'
 arch=('any')
-depends=('bash' 'ncurses-bin' 'python3' 'git' 'wget' 'python3-requests' 'curl' 'coreutils' 'sudo' 'jq')
+depends=('bash' 'bash-completion' 'ncurses-bin' 'python3' 'git' 'wget' 'python3-requests' 'curl' 'coreutils' 'sudo' 'jq' 'gzip')
 provides=('una')
 
-source=('https://github.com/AFK-OS/una/raw/main/una')
-sha256sums=('SKIP')
+source=('https://github.com/AFK-OS/una/raw/main/una' 'https://github.com/AFK-OS/una/raw/main/una-completion')
+sha256sums=('SKIP' 'SKIP')
 
 package() {
     install -D -m755 una -t "${pkgdir}/usr/bin"
+    mv una-completion una
+    mkdir -p "${pkgdir}/usr/share/bash-completion/completions"
+    install -D -m755 una -t "${pkgdir}/usr/share/bash-completion/completions" && rm -f una
 }
diff --git a/una-completion b/una-completion
new file mode 100644
index 0000000..d9c168f
--- /dev/null
+++ b/una-completion
@@ -0,0 +1,25 @@
+#/usr/bin/env bash
+
+set +e
+
+_completions() {
+    SUGGESTIONS=()
+
+    if [[ "$COMP_CWORD" == 1 ]]; then
+        SUGGESTIONS=('install' 'upgrade' 'remove' \
+          'update' 'help' 'list' 'info' 'search' )
+    elif [[ "$COMP_CWORD" == 2 ]] && [[ "${COMP_WORDS[1]}" == remove ]]; then
+        for pkg in $(dpkg-query --show --showformat '${Package} '); do
+            SUGGESTIONS+=("${pkg}")
+        done
+    elif [[ "$COMP_CWORD" == 2 ]] && ( [[ "${COMP_WORDS[1]}" == install ]] \
+      || [[ "${COMP_WORDS[1]}" == search ]] || [[ "${COMP_WORDS[1]}" == info ]] ); then
+        for pkg in $(cat /var/lib/una/cache | jq -r '.[].Name' | grep "^${COMP_WORDS[$COMP_CWORD]}" || true) $(apt-cache search --names-only "^${COMP_WORDS[$COMP_CWORD]}" 2>/dev/null | sort -d | awk '{print $1}' || true); do
+            SUGGESTIONS+=("${pkg}")
+        done
+    fi
+
+    COMPREPLY=($(compgen -W "${SUGGESTIONS[*]}" "${COMP_WORDS[$COMP_CWORD]}"))
+}
+
+complete -F _completions -- una
\ No newline at end of file