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
+21 -1
View File
@@ -32,6 +32,25 @@ download_imagebuilder() {
echo "$(pwd)/$folder"
}
# =============================================================
# 交互输入函数
# 参数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
}
build() {
# =============================================================
# 设备 Profile(必须与 ImageBuilder 支持的设备一致)
@@ -146,7 +165,8 @@ project_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$project_dir"
# 要构建的 ImmortalWrt 版本, 可以在 https://github.com/immortalwrt/immortalwrt 查询版本号
version="25.12.1"
default_version="25.12.1"
version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version")
# 安装依赖
install_dependencies