frappecli
CLI for managing Frappe Framework instances via REST API.
Installation
CODEBLOCK0
Or from source:
CODEBLOCK1
Configuration
Create ~/.config/frappecli/config.yaml:
CODEBLOCK2
Commands
Site Management
CODEBLOCK3
Document CRUD
CODEBLOCK4
File Management
CODEBLOCK5
Reports
CODEBLOCK6
RPC Methods
CODEBLOCK7
Multi-Site
CODEBLOCK8
Output Formats
CODEBLOCK9
Examples
Bulk Operations
CODEBLOCK10
Integration with jq
CODEBLOCK11
Links
- - Repository: https://github.com/pasogott/frappecli
- Homebrew: INLINECODE1
frappecli
通过REST API管理Frappe Framework实例的命令行工具。
安装
bash
brew tap pasogott/tap
brew install frappecli
或从源码安装:
bash
git clone https://github.com/pasogott/frappecli.git
cd frappecli && uv sync && uv pip install -e .
配置
创建 ~/.config/frappecli/config.yaml:
yaml
sites:
production:
url: https://erp.company.com
apikey: yourapi_key
apisecret: yourapi_secret
staging:
url: https://staging.company.com
apikey: yourstaging_key
apisecret: yourstaging_secret
default_site: production
命令
站点管理
bash
frappecli site doctypes # 列出所有文档类型
frappecli site doctypes --module Core # 按模块筛选
frappecli site info User # 获取文档类型详情
文档CRUD操作
bash
列出文档
frappecli doc list Customer
frappecli doc list Customer --filters {status:Active} --limit 10
获取单个文档
frappecli doc get Customer CUST-001
frappecli doc get Customer CUST-001 --fields name,customer_name,status
创建文档
frappecli doc create Customer --data {customer
name:Acme,customertype:Company}
更新文档
frappecli doc update Customer CUST-001 --data {status:Inactive}
删除文档
frappecli doc delete Customer CUST-001
文件管理
bash
上传文件(默认私有)
frappecli file upload invoice.pdf --doctype Sales Invoice --docname INV-001
上传公开文件
frappecli file upload logo.png --public
下载文件
frappecli file download /private/files/invoice.pdf -o ./downloads/
列出文档关联文件
frappecli file list --doctype Sales Invoice --docname INV-001
报表
bash
运行报表(JSON输出)
frappecli report run General Ledger --filters {company:My Company}
导出为CSV
frappecli report run Accounts Receivable --format csv -o report.csv
RPC方法
bash
调用自定义方法
frappecli rpc frappe.ping
带参数调用
frappecli rpc myapp.api.process
data --args {docid:DOC-001}
多站点管理
bash
使用指定站点
frappecli --site staging doc list Customer
切换默认站点
frappecli config set default_site staging
输出格式
bash
frappecli doc list Customer --format table # 美观表格(默认)
frappecli doc list Customer --format json # JSON格式
frappecli doc list Customer --format csv # CSV格式
示例
批量操作
bash
导出所有活跃客户
frappecli doc list Customer --filters {status:Active} --format csv > customers.csv
获取包含子表的文档
frappecli doc get Sales Invoice INV-001 --fields *
与jq集成
bash
仅获取客户名称
frappecli doc list Customer --format json | jq -r .[].customer_name
按状态统计
frappecli doc list Customer --format json | jq group_by(.status) | map({status: .[0].status, count: length})
链接
- - 仓库地址: https://github.com/pasogott/frappecli
- Homebrew安装: brew install pasogott/tap/frappecli