From 47cf7333b6937046b5b64bc7663f746b013ee9cf Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 20 Jul 2023 21:39:43 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(flatpak-sync)=20Add=20add/install?= =?UTF-8?q?=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The add/install command takes a application id as a second parameter and appends it to the apps list. Afterwards the sync method is called. Refs: #1 --- flatpak-sync/flatpak-sync.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/flatpak-sync/flatpak-sync.sh b/flatpak-sync/flatpak-sync.sh index 6150375..2601f4f 100755 --- a/flatpak-sync/flatpak-sync.sh +++ b/flatpak-sync/flatpak-sync.sh @@ -38,4 +38,31 @@ function sync() { done } -sync +function add() { + local appId="${2:-}" + + if [[ -z "$appId" ]]; then + echo "No application ID given." + exit 1 + fi + + if grep "$appId" "$APPS_LIST_PATH"; then + echo "App already in apps list. Run with sync command to install." + exit 2 + fi + + local appsListFile + appsListFile="$(realpath "$APPS_LIST_PATH")" + echo "$appId" >> "$appsListFile" +} + +cmd="${1:-}" + +case "$cmd" in + a|add|i|install ) + add "$@" + sync + ;; + * ) + sync +esac