debian 开发,modiqi 修复 cf_load_profile 缺失问题。 9 个命令:cf-api/cf-zone/cf-dns/cf-cache/cf-ssl/cf-fw/cf-pagerule/cf-analytics/cf-hostname 支持多账号、域名自动解析 zone_id。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
920 B
Bash
Executable file
32 lines
920 B
Bash
Executable file
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
# cf-api — Cloudflare REST API 底层调用器
|
||
# 用法: cf-api <METHOD> <endpoint> [curl-args...]
|
||
# 示例: cf-api GET /zones
|
||
# cf-api GET /zones/ZONE_ID/dns_records
|
||
# cf-api POST /zones/ZONE_ID/dns_records -d '{"type":"A","name":"test","content":"1.2.3.4"}'
|
||
# 选项: -p <profile> 指定配置 profile(默认 default)
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||
source "$SCRIPT_DIR/cf-lib.sh"
|
||
|
||
cf_parse_profile "$@"
|
||
set -- "${CF_REMAINING_ARGS[@]}"
|
||
|
||
if [[ $# -lt 2 ]]; then
|
||
cat >&2 <<'EOF'
|
||
用法: cf-api <METHOD> <endpoint> [curl-args...]
|
||
示例:
|
||
cf-api GET /zones
|
||
cf-api GET /zones/ZONE_ID/dns_records
|
||
cf-api POST /zones/ZONE_ID/purge_cache -d '{"purge_everything":true}'
|
||
cf-api -p support GET /zones # 使用 support profile
|
||
EOF
|
||
exit 1
|
||
fi
|
||
cf_load_profile
|
||
|
||
METHOD="$1" ENDPOINT="$2"
|
||
shift 2
|
||
|
||
cf_call "$METHOD" "$ENDPOINT" "$@" | cf_pretty
|