(flatpak-sync) Add remove/uninstall command

The remove/uninstall command takes a application id as a second
parameter and removes it from the apps list. Afterwards the sync method
is called.

Refs: #1
This commit is contained in:
Marcel Kapfer 2023-07-20 21:48:41 +02:00
parent 47cf7333b6
commit 38fe45f724
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09

View file

@ -56,6 +56,26 @@ function add() {
echo "$appId" >> "$appsListFile"
}
function remove() {
local appId="${2:-}"
if [[ -z "$appId" ]]; then
echo "No application ID given."
exit 1
fi
if ! grep "$appId" "$APPS_LIST_PATH"; then
echo "App not in apps list."
exit 2
fi
local appsListFile
appsListFile="$(realpath "$APPS_LIST_PATH")"
appsListTmpFile="$(mktemp)"
grep -v "$appId" "$APPS_LIST_PATH" >> "$appsListTmpFile"
mv "$appsListTmpFile" "$appsListFile"
}
cmd="${1:-}"
case "$cmd" in
@ -63,6 +83,10 @@ case "$cmd" in
add "$@"
sync
;;
r|remove|u|uninstall )
remove "$@"
sync
;;
* )
sync
esac