Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(cli): wrapper delegates forward flags verbatim to cli.py

Juan Denis1face0702f61
diff --git a/scripts/test/test_cli.sh b/scripts/test/test_cli.sh
index 29a48732..d9bf9812 100644
--- a/scripts/test/test_cli.sh
+++ b/scripts/test/test_cli.sh
@@ -655,6 +655,46 @@ else
bad "dispatch labels missing from completion:[$not_completed]"
fi
+# --------------------------------------------------------------------------
+# T20 — end-to-end flag passthrough: flags typed after a wrapper command must
+# reach cli.py verbatim (the DO-box live test caught `list-apps --json`
+# silently dropping --json in cmd_list_apps' hand-rolled flag mapping).
+# A fake venv with a recording `python` stub captures exactly what run_cli
+# would execute, through the real executed-mode dispatch.
+# --------------------------------------------------------------------------
+t="$WORK/t20"; mkdir -p "$t/install/backend" "$t/venv/bin"
+printf 'export PATH="%s:$PATH"\n' "$t/venv/bin" > "$t/venv/bin/activate"
+cat > "$t/venv/bin/python" <<'EOF'
+#!/usr/bin/env bash
+printf 'ARGS:%s\n' "$*"
+EOF
+chmod +x "$t/venv/bin/python"
+run_wrapped() {
+ SERVERKIT_DIR="$t/install" SERVERKIT_VENV_DIR="$t/venv" bash "$CLI" "$@" 2>&1
+}
+t20_fail=""
+check_args() {
+ local expected="$1"; shift
+ local out
+ out="$(run_wrapped "$@")" || true
+ printf '%s' "$out" | grep -qF "ARGS:cli.py $expected" \
+ || t20_fail="$t20_fail [$*→$out]"
+}
+check_args 'list-apps --json' list-apps --json
+check_args 'list-apps --all' list-apps -a
+check_args 'list-users --json' list-users --json
+check_args 'list-servers --json' list-servers --json
+check_args 'db-migrate' migrate-db
+check_args 'manifest plan --project 1 --json' manifest plan --project 1 --json
+check_args 'services list --json' services list --json
+check_args 'status --json' panel-status --json
+check_args 'doctor --repair --yes' panel-doctor --repair --yes
+if [ -z "$t20_fail" ]; then
+ ok "executed-mode flag passthrough: wrapper commands reach cli.py verbatim"
+else
+ bad "flags lost between wrapper and cli.py:$t20_fail"
+fi
+
# --------------------------------------------------------------------------
printf '\n%d passed, %d failed, %d skipped\n\n' "$PASS" "$FAIL" "$SKIP"
[ "$FAIL" -eq 0 ]
diff --git a/serverkit b/serverkit
index 5a88e95a..5febefe4 100644
--- a/serverkit
+++ b/serverkit
@@ -639,7 +639,7 @@ cmd_unlock_user() {
cmd_list_users() {
check_installed
- run_cli list-users
+ run_cli list-users "$@"
}
cmd_make_admin() {
@@ -827,7 +827,7 @@ cmd_deploy_template() {
cmd_list_servers() {
check_installed
- run_cli list-servers
+ run_cli list-servers "$@"
}
cmd_deployment_status() {
@@ -838,12 +838,13 @@ cmd_deployment_status() {
cmd_list_apps() {
check_installed
- # Pass --all flag if provided
- if [ "$1" = "--all" ] || [ "$1" = "-a" ]; then
- run_cli list-apps --all
- else
- run_cli list-apps
- fi
+ # Forward flags verbatim (--all, --json, …); -a stays as the legacy alias.
+ local arg args=()
+ for arg in "$@"; do
+ [ "$arg" = "-a" ] && arg="--all"
+ args+=("$arg")
+ done
+ run_cli list-apps "${args[@]}"
}
cmd_start_app() {
@@ -1445,7 +1446,8 @@ case "${1:-help}" in
cmd_unlock_user
;;
list-users)
- cmd_list_users
+ shift
+ cmd_list_users "$@"
;;
make-admin)
cmd_make_admin
@@ -1505,13 +1507,15 @@ case "${1:-help}" in
cmd_deploy_template "$@"
;;
list-servers)
- cmd_list_servers
+ shift
+ cmd_list_servers "$@"
;;
deployment-status)
cmd_deployment_status "$@"
;;
list-apps)
- cmd_list_apps "$2"
+ shift
+ cmd_list_apps "$@"
;;
start-app)
cmd_start_app "$2"