feat(bypass): allow --username/--password/--full-name for unattended runs
CI / Bash Syntax Check (push) Successful in 3s
CI / Markdown Lint (push) Successful in 6s
CI / ShellCheck (push) Successful in 2m8s

This commit is contained in:
2026-11-09 11:07:10 +08:00
parent 59487b693e
commit d43c23135f
8 changed files with 183 additions and 34 deletions
+57
View File
@@ -45,3 +45,60 @@ prompt_password() {
fi
done
}
# Account credentials: CLI flags (--username/--password/--full-name) win over
# interactive prompts so bypass/admin/dualboot can run unattended.
OPT_USERNAME="${OPT_USERNAME:-}"
OPT_PASSWORD="${OPT_PASSWORD:-}"
OPT_REALNAME="${OPT_REALNAME:-}"
parse_account_opts() {
ACCOUNT_ARGS=()
while [ $# -gt 0 ]; do
case "$1" in
--username|--password|--full-name)
local key="$1"
if [ $# -lt 2 ] || [ -z "$2" ] || [[ "$2" == --* ]]; then
error_exit "$key requires a value"
fi
case "$key" in
--username) OPT_USERNAME="$2" ;;
--password) OPT_PASSWORD="$2" ;;
--full-name) OPT_REALNAME="$2" ;;
esac
shift 2 ;;
*) ACCOUNT_ARGS+=("$1"); shift ;;
esac
done
}
acquire_username() {
local var_name="$1"
if [ -n "$OPT_USERNAME" ]; then
local msg
msg=$(validate_username "$OPT_USERNAME" 2>&1) || error_exit "Invalid --username: $msg"
eval "$var_name=\"\$OPT_USERNAME\""
else
prompt_username "$var_name"
fi
}
acquire_password() {
local var_name="$1"
if [ -n "$OPT_PASSWORD" ]; then
local msg
msg=$(validate_password "$OPT_PASSWORD" 2>&1) || error_exit "Invalid --password: $msg"
eval "$var_name=\"\$OPT_PASSWORD\""
else
prompt_password "$var_name"
fi
}
acquire_realname() {
local var_name="$1"
if [ -n "$OPT_REALNAME" ]; then
eval "$var_name=\"\$OPT_REALNAME\""
else
prompt_default "$var_name" "Full name" "Apple"
fi
}