All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 1/2] opkg-bash-completion: add simple completions for opkg
@ 2020-01-21 16:58 Jacob Stiffler
  2020-01-21 16:58 ` [RFC][PATCH 2/2] packagegroup-arago-base: add opkg-bash-completion Jacob Stiffler
  2020-01-21 20:32 ` [RFC][PATCH 1/2] opkg-bash-completion: add simple completions for opkg Denys Dmytriyenko
  0 siblings, 2 replies; 3+ messages in thread
From: Jacob Stiffler @ 2020-01-21 16:58 UTC (permalink / raw)
  To: meta-arago

This is a simpe start to bash completions for opkg. Initialy, this can
complete current supported verbs (static) and complete package names
(dynamic).

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 .../recipes-devtools/opkg/opkg-bash-completion.bb  | 15 +++++++++++++
 .../opkg/opkg-bash-completion/opkg-bash-completion | 26 ++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion.bb
 create mode 100644 meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion/opkg-bash-completion

diff --git a/meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion.bb b/meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion.bb
new file mode 100644
index 0000000..74e4964
--- /dev/null
+++ b/meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion.bb
@@ -0,0 +1,15 @@
+SUMMARY = "bash-completions for opkg"
+LICENSE = "MIT"
+
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+SRC_URI = "file://opkg-bash-completion"
+
+do_install() {
+    install -d ${D}${datadir}/bash-completion/completions
+    install -m 0644 ${WORKDIR}/opkg-bash-completion \
+                    ${D}${datadir}/bash-completion/completions/opkg
+}
+
+FILES_${PN} = "${datadir}/bash-completion/completions/opkg"
+RDEPENDS_${PN} = "bash-completion"
diff --git a/meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion/opkg-bash-completion b/meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion/opkg-bash-completion
new file mode 100644
index 0000000..5b0b4e1
--- /dev/null
+++ b/meta-arago-extras/recipes-devtools/opkg/opkg-bash-completion/opkg-bash-completion
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# TBD: parse "opkg --help" to get this list
+OPKG_COMMANDS="update upgrade install configure remove clean flag list list-installed list-upgradable list-changed-conffiles files search find info status download compare-versions print-architecture depends whatdepends whatdependsrec whatrecommends whatsuggests whatprovides whatconflicts whatreplaces"
+
+_opkg_completions() {
+    if [ ${#COMP_WORDS[@]} -eq 2 ]
+    then
+        COMPREPLY=($(compgen -W "${OPKG_COMMANDS}" "${COMP_WORDS[1]}"))
+        return
+    fi
+
+    # TBD: add more cases, support options
+    case "${COMP_WORDS[1]}" in
+        install|files|info|status|download)
+            COMPREPLY=($(compgen -W "$(opkg list | sed -e 's| .*$||')" -- "${COMP_WORDS[$COMP_CWORD]}"));;
+        depends|whatdepends|whatdependsrec|whatrecommends|whatsuggests|whatprovides|whatconflicts|whatreplaces)
+            COMPREPLY=($(compgen -W "-A $(opkg list | sed -e 's| .*$||')" -- "${COMP_WORDS[$COMP_CWORD]}"));;
+        remove)
+            COMPREPLY=($(compgen -W "$(opkg list-installed | sed -e 's| .*$||')" -- "${COMP_WORDS[$COMP_CWORD]}"));;
+        upgrade)
+            COMPREPLY=($(compgen -W "$(opkg list-upgradable | sed -e 's| .*$||')" -- "${COMP_WORDS[$COMP_CWORD]}"));;
+    esac
+}
+
+complete -F _opkg_completions opkg
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-21 20:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-21 16:58 [RFC][PATCH 1/2] opkg-bash-completion: add simple completions for opkg Jacob Stiffler
2020-01-21 16:58 ` [RFC][PATCH 2/2] packagegroup-arago-base: add opkg-bash-completion Jacob Stiffler
2020-01-21 20:32 ` [RFC][PATCH 1/2] opkg-bash-completion: add simple completions for opkg Denys Dmytriyenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.