install-duckdb

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Arguments:
$@
Each extension argument has the form
name
or
name@repo
.
  • name
    INSTALL name;
  • name@repo
    INSTALL name FROM repo;
参数:
$@
每个扩展参数的格式为
name
name@repo
  • name
    INSTALL name;
  • name@repo
    INSTALL 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.cli
Then 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
--update
is present in
$@
, remove it from the argument list and set mode to update. Otherwise mode is install.
如果
$@
中存在
--update
,则从参数列表中移除该参数,并将模式设置为更新。 否则模式为安装

Step 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
    ==
    LATEST
    → report DuckDB CLI is up to date.
  • If
    CURRENT
    !=
    LATEST
    → ask the user:
    DuckDB CLI is outdated (installed:
    CURRENT
    , latest:
    LATEST
    ). Upgrade now?
    If the user agrees, detect the platform and run the appropriate upgrade command:
    • macOS (
      brew
      available):
      brew upgrade duckdb
    • Linux:
      curl -fsSL https://install.duckdb.org | sh
    • Windows:
      winget upgrade DuckDB.cli
Then update extensions:
  • No extension names → update all:
    UPDATE EXTENSIONS;
  • With extension names → update in a single call (ignore
    @repo
    ):
    UPDATE 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
    ==
    LATEST
    → 提示DuckDB CLI已是最新版本。
  • 如果
    CURRENT
    !=
    LATEST
    → 询问用户:
    DuckDB CLI版本过旧(已安装版本:
    CURRENT
    ,最新版本:
    LATEST
    )。是否立即升级?
    如果用户同意,检测平台并运行对应的升级命令:
    • macOS(已安装
      brew
      ):
      brew upgrade duckdb
    • Linux:
      curl -fsSL https://install.duckdb.org | sh
    • Windows:
      winget upgrade DuckDB.cli
然后更新扩展:
  • 未指定扩展名称 → 更新所有扩展:
    UPDATE EXTENSIONS;
  • 指定了扩展名称 → 在单次调用中更新指定扩展(忽略
    @repo
    部分):
    UPDATE 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>, ...);"

调用完成后报告执行成功或失败。