Add delete functionality

This commit is contained in:
Aleksandar Puharic 2023-03-22 02:34:13 +01:00
parent f79da27583
commit 1b62dba10a
Signed by: xZero707
GPG Key ID: 3CC53DCAA9C237BB

View File

@ -71,6 +71,24 @@ check() {
return 1 return 1
} }
# Delete plugin
# $1 - plugin slug
# Returns 0 on success, X on failure
delete() {
TARGET_PLUGINS_DIR="${TARGET_PLUGINS_DIR:?delete: TARGET_PLUGINS_DIR is required}"
PLUGIN_SLUG="${1:?delete: PLUGIN_SLUG is required}"
PLUGIN_PATH="${TARGET_PLUGINS_DIR}/${PLUGIN_SLUG}"
# Check if plugin directory exists
if [ ! -d "${PLUGIN_PATH}" ]; then
return 1
fi
rm -rf "${PLUGIN_PATH}"
return $?
}
# Main function # Main function
main() { main() {
COMMAND="${1:?COMMAND is required}" COMMAND="${1:?COMMAND is required}"
@ -92,6 +110,10 @@ main() {
check "${@:2}" check "${@:2}"
return $? return $?
;; ;;
delete)
delete "${@:2}"
return $?
;;
*) *)
echo "Error: Unknown command '${COMMAND}'" echo "Error: Unknown command '${COMMAND}'"
return 1 return 1