mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-10-23 03:27:43 +09:00
Stop serverkit update --help from updating
update, uninstall and cleanup-apps silently dropped any flag they did not know, so 'serverkit update --help' ran a real update. --help now prints usage and an unknown flag fails before anything runs.
This commit is contained in:
1 parent
727310a703
commit
fbed88ea35
2 files changed
+68
-3
No files matched your search
@@ -97,6 +97,45 @@ else
|
||||
bad "update --branch dev forwarding broken: [$out]"
|
||||
fi
|
||||
|
||||
# T1c — unknown flags used to be dropped and the update ran anyway, so
|
||||
# `serverkit update --help` updated the box. Help prints usage; an unknown
|
||||
# flag fails; neither reaches the updater.
|
||||
for args in "--help" "--frobnicate"; do
|
||||
out="$(
|
||||
set -Eeuo pipefail
|
||||
check_root() { :; }
|
||||
check_installed() { :; }
|
||||
INSTALL_DIR="$t"; VENV_DIR="$t/venv"
|
||||
cmd_update $args 2>&1
|
||||
)"
|
||||
rc=$?
|
||||
if printf '%s' "$out" | grep -q 'ARGS:'; then
|
||||
bad "update $args ran the updater: [$out]"
|
||||
elif ! printf '%s' "$out" | grep -q 'Usage: serverkit update'; then
|
||||
bad "update $args printed no usage: rc=$rc out=[$out]"
|
||||
elif [ "$args" = "--help" ] && [ "$rc" -ne 0 ]; then
|
||||
bad "update --help exited $rc"
|
||||
elif [ "$args" != "--help" ] && [ "$rc" -eq 0 ]; then
|
||||
bad "update $args exited 0"
|
||||
else
|
||||
ok "update $args prints usage and never runs the updater (rc=$rc)"
|
||||
fi
|
||||
done
|
||||
|
||||
for args in "--help" "--frobnicate"; do
|
||||
out="$( set -Eeuo pipefail; check_root() { :; }; cmd_uninstall $args 2>&1 )"
|
||||
rc=$?
|
||||
if printf '%s' "$out" | grep -q 'This will remove ServerKit'; then
|
||||
bad "uninstall $args went on to the uninstall: [$out]"
|
||||
elif [ "$args" = "--help" ] && [ "$rc" -eq 0 ]; then
|
||||
ok "uninstall --help prints usage only"
|
||||
elif [ "$args" != "--help" ] && [ "$rc" -ne 0 ]; then
|
||||
ok "uninstall with an unknown flag fails (rc=$rc)"
|
||||
else
|
||||
bad "uninstall $args: rc=$rc out=[$out]"
|
||||
fi
|
||||
done
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# T2 — L6: cmd_start must warn (not raw-abort) when systemctl/docker fail
|
||||
# (partial installs, non-systemd boxes). cmd_stop already had these guards.
|
||||
|
||||
@@ -598,6 +598,14 @@ cmd_branch() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
update_usage() {
|
||||
echo "Usage: serverkit update [options]"
|
||||
echo " --branch <name> Switch to specific branch (e.g., dev)"
|
||||
echo " --release [vX.Y.Z] Update from release tarball"
|
||||
echo " --force Force update even if already latest"
|
||||
echo " --dry-run Show what would change without applying"
|
||||
}
|
||||
|
||||
cmd_update() {
|
||||
local update_args=()
|
||||
|
||||
@@ -632,8 +640,16 @@ cmd_update() {
|
||||
update_args+=("--dry-run")
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
update_usage
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
# An unknown flag used to be dropped and the update ran
|
||||
# anyway — `update --help` updated the box.
|
||||
print_error "Unknown option for update: $1"
|
||||
update_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -666,7 +682,12 @@ cmd_uninstall() {
|
||||
--keep-data) keep_data=1; shift ;;
|
||||
--yes|-y) assume_yes=1; shift ;;
|
||||
--dry-run|-n) dry_run=1; shift ;;
|
||||
*) shift ;;
|
||||
--help|-h)
|
||||
echo "Usage: serverkit uninstall [--purge|--delete-volumes] [--keep-data] [--yes] [--dry-run]"
|
||||
return 0 ;;
|
||||
*)
|
||||
print_error "Unknown option for uninstall: $1"
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -810,8 +831,13 @@ cmd_cleanup_apps() {
|
||||
KEEP_DB="--keep-db"
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
run_cli cleanup-apps --help
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
print_error "Unknown option for cleanup-apps: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in new issue
Block a user