命令行工具

命令参考

AnyToURL CLI 全部命令详解 — upload、text、url、whoami 和 config。

全局选项

所有命令均支持以下参数:

参数说明
-u, --api-url <url>覆盖已配置的 API 地址
-k, --api-key <key>覆盖已配置的 API 密钥
-q, --quiet仅输出 URL(每行一个)
-j, --json以 JSON 格式输出

upload

上传一个或多个文件。支持本地文件、通配符和 stdin。

anytourl upload <files...>

示例

# 单个文件
anytourl upload screenshot.png

# 多个文件
anytourl upload file1.txt file2.pdf image.jpg

# 从 stdin 读取
cat photo.png | anytourl upload -
echo "hello" | anytourl upload --filename hello.txt

# 安静模式 — 仅返回 URL
anytourl upload photo.png -q

选项

参数说明
--filename <name>为 stdin 输入指定文件名

JSON 输出

使用 -j 时,每个结果包含:

字段类型说明
idstring唯一文件 ID
urlstring分享链接
keystring文件 key
filenamestring原始文件名
sizenumber文件大小(字节)
typestring文件类型
zonestring存储区域
expiresAtstring | null过期时间(永久则为 null)
permanentboolean是否永久保存
dedupedboolean是否去重

text

创建文本粘贴,支持内联文本、文件和 stdin。

anytourl text [options]

示例

# 内联文本
anytourl text -c "Hello, world!"

# 从文件读取
anytourl text -f notes.md

# 从 stdin 读取
cat log.txt | anytourl text
echo "quick note" | anytourl text -t "My Note"

# JSON 输出
anytourl text -c "debug data" -j

选项

参数说明
-c, --content <text>要粘贴的文本内容
-f, --file <path>从文件读取内容
-t, --title <title>设置粘贴标题

JSON 输出

字段类型说明
idstring唯一粘贴 ID
urlstring分享链接
filenamestring生成的文件名
sizenumber内容大小(字节)
typestring文件类型
contentTypestringMIME 类型

url

缩短 URL。

anytourl url <url>

示例

# 缩短链接
anytourl url https://example.com/very/long/path/to/page

# 仅获取短链
anytourl url https://example.com/long -q

# JSON 输出
anytourl url https://example.com/long -j

JSON 输出

字段类型说明
idstring唯一 ID
urlstring短链接
shortUrlstring短链接(别名)
shortCodestring短码标识
originalUrlstring原始长链接

whoami

显示账户信息、套餐和配额使用情况。

anytourl whoami

JSON 输出

字段类型说明
user.namestring账户名称
user.emailstring账户邮箱
plan.displayNamestring当前套餐名称
quota.storageobject存储用量(usedlimit、格式化版本)
quota.monthlyUploadobject月上传用量
quota.bandwidthobject带宽用量
featuresobject功能标记(apiAccesscustomShortLinks 等)
fileRetention.hoursnumber | null文件保留时长
fileRetention.permanentboolean是否永久保存

config

管理 CLI 配置。设置存储在 ~/.anytourl

anytourl config <subcommand>

子命令

# 设置值
anytourl config set apiUrl https://anytourl.com
anytourl config set apiKey sk-your-api-key

# 获取值
anytourl config get apiKey

# 列出所有配置
anytourl config list

# 删除某个 key
anytourl config delete apiKey

# 清除所有配置
anytourl config clear

可用的 key:apiUrlapiKey


集成模式

脚本中捕获 URL

URL=$(anytourl upload report.pdf -q)
echo "Report uploaded: $URL"

CI/CD 流水线

# 上传构建产物
anytourl upload dist/*.js -q -k "$ANYTOURL_API_KEY" -u https://anytourl.com

管道链

# 生成 → 上传 → 通知
tar czf - ./logs | anytourl upload --filename logs.tar.gz -q | xargs -I{} curl -X POST "$WEBHOOK" -d '{"url":"{}"}'

npx 一次性使用

无需全局安装:

npx anytourl upload file.txt -k sk-your-key -u https://anytourl.com