feat: 增加交互式变量.

This commit is contained in:
Olia Lisa
2026-07-12 18:18:58 +08:00
parent 76015e9cb5
commit 40c631166a
4 changed files with 85 additions and 6 deletions
+20 -1
View File
@@ -141,12 +141,31 @@ build() {
echo -e "固件输出: ${PROJECT_OUTPUT_DIR}"
}
# =============================================================
# 交互输入函数
# 参数1: 提示信息
# 参数2: 默认值
# 返回: 用户输入值,直接回车返回默认值
# =============================================================
ask_input() {
local prompt="$1"
local default="$2"
read -p "${prompt} [默认: ${default}]: " value
if [ -z "$value" ]; then
echo "$default"
else
echo "$value"
fi
}
project_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$project_dir"
# 要构建的 ImmortalWrt 版本
version="25.12.1"
default_version="25.12.1"
version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version")
install_dependencies