#!/usr/bin/env bash set -u usage() { printf 'Usage: %s install|uninstall|reload|reset all|namlv2|lsp|dragonfly-reverb|pipewire|mod-host-ports|mod-host|mod-ui|reconcile|midi-bridge|sooperlooper [--force-reference (install mod-ui only)]\n' "$0" >&2 exit 2 } force_args=() if [[ $# -eq 3 && "$3" == "--force-reference" && "$1" == "install" && "$2" == "mod-ui" ]]; then force_args=(--force-reference) elif [[ $# -ne 2 ]]; then usage fi action=$1 target=$2 case "$action" in install|uninstall|reload|reset) ;; *) usage ;; esac case "$target" in all) targets=(pipewire namlv2 lsp dragonfly-reverb) ;; namlv2|lsp|dragonfly-reverb|pipewire|mod-host-ports|mod-host|mod-ui|reconcile|midi-bridge|sooperlooper) targets=("$target") ;; *) usage ;; esac if [[ "$action" == reset && "$target" != mod-ui ]]; then usage fi script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) status=0 for component in "${targets[@]}"; do printf '%s\n' "== $action $component ==" if ! python3 "$script_dir/deploy.py" "$action" "$component" "${force_args[@]}"; then status=1 fi done exit "$status"