跳转到内容

cnb-rs download

cnb-rs download [OPTIONS] [COMMAND]

从仓库下载 文件 / archive / LFS 链接的统一入口。

三种下载模式

子命令 / 模式适用场景
默认 / --files按路径下载若干文件(支持 glob include/exclude、并发)
archive下载整仓 / 子路径的 zip archive
lfs-link获取 LFS 文件预签直链(不下载、输出到 stdout)

向后兼容

旧脚本 cnb-rs download --files a,b --ref main 仍能跑(不带子命令时默认 files 行为)。 新名 cnb-rs download files … 并未暴露为显式子命令,二者同义。

文件下载选项(默认模式)

  • --files <FILES>: 要下载的文件路径(逗号分隔或多次指定)
  • --ref <REF>: Git 引用(分支/tag/commit),默认使用默认分支
  • --local-dir <DIR>: 本地下载目录(默认:.
  • --include <PATTERN>: 包含的文件 glob 模式(可多次指定)
  • --exclude <PATTERN>: 排除的文件 glob 模式(可多次指定)
  • -c, --concurrency <N>: 最大并发下载数(默认:4

继承的全局选项:

  • --repo <REPO>: 指定仓库路径(格式:group/repo
  • --domain <DOMAIN>: 指定目标域名(默认:cnb.cool

示例

bash
# 下载指定文件(默认 files 行为)
$ cnb-rs download --files README.md,LICENSE

# 下载到指定目录
$ cnb-rs download --files src/ --local-dir ./output

# 使用 glob 模式过滤
$ cnb-rs download --include "*.rs" --exclude "test_*"

# 从指定分支下载
$ cnb-rs download --files docs/ --ref develop

# 下载整仓 archive(zip)
$ cnb-rs download archive HEAD -o repo.zip

# 拿 LFS 文件预签链接(输出到 stdout)
$ cnb-rs download lfs-link <oid>

另请参阅

Released under the MIT License.