(flatpak-sync) Fail add/remove if app id is commented out

Handling commented out apps would perhaps be interesting to add in the
future. But at this point I think the the people using this script
either want to go fully declarative and not use the add/remove
commands at all or do not want to edit the apps list file themselves
and therefore will not have and comments in them.

Refs: #1
This commit is contained in:
Marcel Kapfer 2023-07-20 21:54:09 +02:00
parent 38fe45f724
commit 00fc8ea318
Signed by: mmk2410
GPG Key ID: CADE6F0C09F21B09
1 changed files with 13 additions and 3 deletions

View File

@ -46,11 +46,16 @@ function add() {
exit 1 exit 1
fi fi
if grep "$appId" "$APPS_LIST_PATH"; then if grep -q "# $appId" "$APPS_LIST_PATH"; then
echo "App already in apps list. Run with sync command to install." echo "App already in apps list but commented out. Manual fix of the app list file necessary."
exit 2 exit 2
fi fi
if grep -q "$appId" "$APPS_LIST_PATH"; then
echo "App already in apps list. Run with sync command to install."
exit 3
fi
local appsListFile local appsListFile
appsListFile="$(realpath "$APPS_LIST_PATH")" appsListFile="$(realpath "$APPS_LIST_PATH")"
echo "$appId" >> "$appsListFile" echo "$appId" >> "$appsListFile"
@ -64,7 +69,12 @@ function remove() {
exit 1 exit 1
fi fi
if ! grep "$appId" "$APPS_LIST_PATH"; then if grep -q "# $appId" "$APPS_LIST_PATH"; then
echo "App already in apps list but commented out. No remove possible."
exit 2
fi
if ! grep -q "$appId" "$APPS_LIST_PATH"; then
echo "App not in apps list." echo "App not in apps list."
exit 2 exit 2
fi fi