install-duckdb
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseArguments:
$@Each extension argument has the form or .
namename@repo- →
nameINSTALL name; - →
name@repoINSTALL name FROM repo;
参数:
$@每个扩展参数的格式为或。
namename@repo- →
nameINSTALL name; - →
name@repoINSTALL name FROM repo;
Step 1 — Locate DuckDB
步骤1 — 定位DuckDB
bash
DUCKDB=$(command -v duckdb)If not found, tell the user:
DuckDB is not installed. Install it first with one of:
- macOS:
brew install duckdb- Linux:
curl -fsSL https://install.duckdb.org | sh- Windows:
winget install DuckDB.cliThen re-run./duckdb-skills:install-duckdb
Stop if DuckDB is not found.
bash
DUCKDB=$(command -v duckdb)如果未找到,提示用户:
DuckDB尚未安装。 请先通过以下任意方式安装:
- macOS:
brew install duckdb- Linux:
curl -fsSL https://install.duckdb.org | sh- Windows:
winget install DuckDB.cli安装完成后重新运行。/duckdb-skills:install-duckdb
如果未找到DuckDB则终止流程。
Step 2 — Check for --update flag
步骤2 — 检查--update标识
If is present in , remove it from the argument list and set mode to update.
Otherwise mode is install.
--update$@如果中存在,则从参数列表中移除该参数,并将模式设置为更新。
否则模式为安装。
$@--updateStep 3 — Build and run statements
步骤3 — 构建并执行语句
Install mode:
Parse each remaining argument:
- If it contains , split on
@→@INSTALL <name> FROM <repo>; - Otherwise →
INSTALL <name>;
Run all in a single DuckDB call:
bash
"$DUCKDB" :memory: -c "INSTALL <ext1>; INSTALL <ext2> FROM <repo2>; ..."Update mode:
First, check if the DuckDB CLI itself is up to date:
bash
CURRENT=$(duckdb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
LATEST=$(curl -fsSL https://duckdb.org/data/latest_stable_version.txt)-
If==
CURRENT→ report DuckDB CLI is up to date.LATEST -
If!=
CURRENT→ ask the user:LATESTDuckDB CLI is outdated (installed:, latest:CURRENT). Upgrade now?LATESTIf the user agrees, detect the platform and run the appropriate upgrade command:- macOS (available):
brewbrew upgrade duckdb - Linux:
curl -fsSL https://install.duckdb.org | sh - Windows:
winget upgrade DuckDB.cli
- macOS (
Then update extensions:
- No extension names → update all:
UPDATE EXTENSIONS; - With extension names → update in a single call (ignore ):
@repoUPDATE EXTENSIONS (<name1>, <name2>, ...);
bash
"$DUCKDB" :memory: -c "UPDATE EXTENSIONS;"安装模式:
解析剩余的每个参数:
- 如果包含,按
@拆分 →@INSTALL <name> FROM <repo>; - 否则 →
INSTALL <name>;
在单次DuckDB调用中执行所有语句:
bash
"$DUCKDB" :memory: -c "INSTALL <ext1>; INSTALL <ext2> FROM <repo2>; ..."更新模式:
首先,检查DuckDB CLI本身是否为最新版本:
bash
CURRENT=$(duckdb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
LATEST=$(curl -fsSL https://duckdb.org/data/latest_stable_version.txt)-
如果==
CURRENT→ 提示DuckDB CLI已是最新版本。LATEST -
如果!=
CURRENT→ 询问用户:LATESTDuckDB CLI版本过旧(已安装版本:,最新版本:CURRENT)。是否立即升级?LATEST如果用户同意,检测平台并运行对应的升级命令:- macOS(已安装):
brewbrew upgrade duckdb - Linux:
curl -fsSL https://install.duckdb.org | sh - Windows:
winget upgrade DuckDB.cli
- macOS(已安装
然后更新扩展:
- 未指定扩展名称 → 更新所有扩展:
UPDATE EXTENSIONS; - 指定了扩展名称 → 在单次调用中更新指定扩展(忽略部分):
@repoUPDATE EXTENSIONS (<name1>, <name2>, ...);
bash
"$DUCKDB" :memory: -c "UPDATE EXTENSIONS;"or
或
"$DUCKDB" :memory: -c "UPDATE EXTENSIONS (<ext1>, <ext2>, ...);"
Report success or failure after the call completes."$DUCKDB" :memory: -c "UPDATE EXTENSIONS (<ext1>, <ext2>, ...);"
调用完成后报告执行成功或失败。