XMind ABS Admin CLI — Rust 命令行工具,用于管理 XMind ABS Admin 后端(SaaS 商业/会员忠诚度平台)。
git clone https://github.com/xmindltd/xmind-abs-cli.git
cd xmind-abs-cli
cargo build --release
# 二进制文件: target/release/abs-cli前往 Releases 页面下载对应平台的预编译二进制文件。
| 平台 | 文件 |
|---|---|
| Linux x86_64 | abs-cli-x86_64-linux.tar.gz |
| Linux aarch64 | abs-cli-aarch64-linux.tar.gz |
| macOS x86_64 | abs-cli-x86_64-macos.tar.gz |
| macOS Apple Silicon | abs-cli-aarch64-macos.tar.gz |
| Windows x86_64 | abs-cli-x86_64-windows.exe.zip |
# 1. 配置
abs-cli configure
# 2. 登录
abs-cli login
# 3. 使用
abs-cli coupons list
abs-cli users list -o json
abs-cli products get <id>运行 abs-cli configure 进入交互式向导,或手动编辑 ~/.config/abs-cli/config.toml:
current_profile = "dev"
[profiles.dev]
base_url = "http://localhost:13000/api"
cognito_pool_id = "us-east-2_xxxxx"
cognito_client_id = "xxxxxxx"
cognito_region = "us-east-2"
[profiles.staging]
base_url = "https://staging-api.example.com"
cognito_pool_id = "us-east-2_xxxxx"
cognito_client_id = "xxxxxxx"
cognito_region = "us-east-2"--profile > --env > ABS_PROFILE 环境变量 > 已存储的 current_profile
- OAuth2 SSO(推荐):配置 Cognito Pool ID + Client ID + Region,运行
abs-cli login自动打开浏览器 - 密码登录:仅配置 Client ID + Region(无 Pool ID),使用用户名密码登录
- API Token:无 Cognito 配置时,直接输入 API Token
--profile, --env 指定 profile
-o, --output 输出格式 (table / json)
--api-url 覆盖 API 基础 URL
| 命令 | 说明 |
|---|---|
abs-cli login |
登录 |
abs-cli logout |
登出 |
abs-cli configure interactive |
交互式配置向导 |
abs-cli configure show |
显示当前配置 |
abs-cli configure list-profiles |
列出所有 profile |
所有领域模块支持通用 CRUD 子命令:list(别名 ls)、get、create、update、delete
| 命令 | 说明 |
|---|---|
coupons |
优惠券管理 |
coupon-tags |
优惠券标签 |
products |
产品管理 |
bundles |
产品捆绑包 |
packages |
套餐管理 |
features |
功能特性 |
feature-tags |
功能标签 |
redeem-codes |
兑换码 |
redemptions |
兑换记录 |
redemption-history |
兑换历史 |
entitlements |
权益管理 |
users |
用户管理 |
admin-users |
管理员用户 |
admin-policies |
管理员策略 |
admin-user-groups |
管理员用户组 |
affiliates |
联盟成员 |
affiliate-commissions |
联盟佣金 |
commission-settlements |
佣金结算 |
partners |
合作伙伴 |
partner-orders |
合作伙伴订单 |
api-secrets |
API 密钥 |
identity-providers |
身份提供商 |
server-config |
服务器配置 |
tenants |
租户管理 |
# 列出所有优惠券(表格格式)
abs-cli coupons list
# JSON 输出
abs-cli coupons list -o json
# 分页
abs-cli coupons list --page 2 --limit 10
# 查看详情
abs-cli coupons get <coupon-id>
# 使用指定 profile
abs-cli --profile staging users list
# 直接指定 API 地址
abs-cli --api-url https://api.example.com products list- Rust 1.75+ (edition 2021)
cargo build # 构建
cargo build --release # 发布构建
cargo test # 运行测试
cargo run -- --help # 查看 CLI 帮助abs-cli/
├── abs-cli/ # 二进制 crate (CLI 应用)
│ └── src/
│ ├── main.rs # 入口
│ ├── cli.rs # Clap CLI 定义
│ ├── common.rs # 客户端工厂 + token 刷新
│ ├── commands/ # 认证/配置命令
│ └── {module}/ # 26 个领域模块
├── abs-cli-core/ # 库 crate (共享基础设施)
│ └── src/
│ ├── client/ # HTTP 客户端
│ ├── config/ # 配置管理
│ └── output/ # 输出格式化
└── .github/workflows/ # CI/CD
- 创建
src/{module_name}/mod.rs—Subcommand枚举 +handle()分发器 - 创建
src/{module_name}/handler.rs— async handler - 创建
src/{module_name}/types.rs— serde 请求/响应结构体 - 在
main.rs添加mod {module_name}; - 在
cli.rs添加枚举变体和use语句