Bring! Add Items CLI
Overview
CLI for adding items to Bring! shopping lists. Supports quick single-item mode, batch mode, stdin/pipe input, and interactive mode.
When to Use
Use this skill when:
- - User wants to add items to a Bring! shopping list
- Adding single item with optional specification (e.g., "Milk 1L")
- Adding multiple items at once (batch mode)
- Piping items from a file or other command
- Need to preview additions with dry-run
- Need JSON output for scripting
Don't use when:
- - User wants to browse recipes (use bring-recipes instead)
- User wants to remove items from a list
- User wants to view current list contents
Quick Reference
| Command | Purpose |
|---|
| INLINECODE0 | Add single item with specification |
| INLINECODE1 |
Add multiple comma-separated items |
|
bring-add - | Read items from stdin |
|
bring-add | Interactive mode (TTY only) |
|
bring-add lists | Show available shopping lists |
|
bring-add --dry-run ... | Preview without modifying |
Environment variables:
CODEBLOCK0
Installation
CODEBLOCK1
Common Workflows
Add a single item:
CODEBLOCK2
Add to specific list:
CODEBLOCK3
Batch add multiple items:
CODEBLOCK4
Pipe from file:
CODEBLOCK5
Preview before adding:
CODEBLOCK6
Get JSON output:
CODEBLOCK7
List available lists:
CODEBLOCK8
Flags Reference
| Flag | Description |
|---|
| INLINECODE6 | Target list (name or UUID) |
| INLINECODE7 |
Comma-separated items |
|
-n, --dry-run | Preview without modifying |
|
-q, --quiet | Suppress non-error output |
|
-v, --verbose | Show detailed progress |
|
--json | Output JSON to stdout |
|
--no-color | Disable colored output |
|
--no-input | Never prompt; fail if input required |
Input Format
Items follow the pattern: ItemName [Specification]
| Input | Item | Spec |
|---|
| INLINECODE15 | Tomatoes | 500g |
| INLINECODE16 |
Oat milk | 1L |
|
Red onions 3 | Red onions | 3 |
|
Cheese | Cheese | (empty) |
Rule: Last word becomes specification if it contains a number or unit (g, kg, L, ml, Stück, pck).
Exit Codes
| Code | Meaning |
|---|
| INLINECODE19 | Success |
| INLINECODE20 |
Generic failure (API error, network) |
|
2 | Invalid usage (bad args, missing input) |
|
3 | Authentication failed |
|
4 | List not found |
|
130 | Interrupted (Ctrl-C) |
Common Mistakes
Forgetting environment variables:
Set BRING_EMAIL and BRING_PASSWORD before running.
Wrong list name:
Use bring-add lists to see available lists and their exact names.
Specification parsing:
The last word is treated as specification only if it looks like a quantity. "Red onions" stays as one item, but "Red onions 3" splits into item "Red onions" with spec "3".
Interactive mode in scripts:
Use --no-input flag in scripts to fail explicitly rather than hang waiting for input.
Implementation Notes
- - Uses
node-bring-api with batchUpdateList() API - Requires Node.js 18.0.0+
- Outputs data to stdout, progress/errors to stderr
- JSON mode available for automation
- Interactive mode only when stdin is a TTY
Bring! Add Items CLI
概述
用于向Bring!购物清单添加物品的命令行工具。支持快速单物品模式、批量模式、标准输入/管道输入以及交互模式。
使用时机
使用此技能的场景:
- - 用户想要向Bring!购物清单添加物品
- 添加单个物品并附带可选规格(例如:牛奶 1升)
- 一次添加多个物品(批量模式)
- 从文件或其他命令通过管道传入物品
- 需要预览添加结果(试运行模式)
- 需要JSON输出用于脚本处理
不应使用的场景:
- - 用户想要浏览食谱(请使用bring-recipes)
- 用户想要从清单中移除物品
- 用户想要查看当前清单内容
快速参考
| 命令 | 用途 |
|---|
| bring-add 物品 规格 | 添加带规格的单个物品 |
| bring-add --batch A, B 1升, C |
添加多个逗号分隔的物品 |
| bring-add - | 从标准输入读取物品 |
| bring-add | 交互模式(仅限终端) |
| bring-add lists | 显示可用购物清单 |
| bring-add --dry-run ... | 预览但不修改 |
环境变量:
bash
export BRING_EMAIL=your@email.com
export BRING_PASSWORD=yourpassword
export BRINGDEFAULTLIST=购物清单 # 可选
安装
bash
cd skills/bring-add
npm install
常见工作流程
添加单个物品:
bash
node index.js 西红柿 500克
node index.js 牛奶
添加到指定清单:
bash
node index.js --list 派对 薯片 3袋
批量添加多个物品:
bash
node index.js --batch 西红柿 500克, 洋葱, 奶酪 200克
从文件管道输入:
bash
cat shopping-list.txt | node index.js -
echo -e 牛奶 1升\n面包\n黄油 | node index.js -
添加前预览:
bash
node index.js --dry-run --batch 苹果 1公斤, 梨
获取JSON输出:
bash
node index.js --json --batch 牛奶, 面包 2>/dev/null
列出可用清单:
bash
node index.js lists
node index.js --json lists
参数参考
| 参数 | 描述 |
|---|
| -l, --list <名称> | 目标清单(名称或UUID) |
| -b, --batch <物品> |
逗号分隔的物品列表 |
| -n, --dry-run | 预览但不修改 |
| -q, --quiet | 抑制非错误输出 |
| -v, --verbose | 显示详细进度 |
| --json | 输出JSON到标准输出 |
| --no-color | 禁用彩色输出 |
| --no-input | 从不提示;如果需要输入则失败 |
输入格式
物品遵循模式:物品名称 [规格]
| 输入 | 物品 | 规格 |
|---|
| 西红柿 500克 | 西红柿 | 500克 |
| 燕麦奶 1升 |
燕麦奶 | 1升 |
| 红洋葱 3个 | 红洋葱 | 3个 |
| 奶酪 | 奶酪 | (空) |
规则:如果最后一个词包含数字或单位(克、公斤、升、毫升、个、包),则将其作为规格。
退出代码
通用失败(API错误、网络问题) |
| 2 | 无效使用(参数错误、缺少输入) |
| 3 | 认证失败 |
| 4 | 清单未找到 |
| 130 | 中断(Ctrl-C) |
常见错误
忘记设置环境变量:
运行前请设置BRINGEMAIL和BRINGPASSWORD。
清单名称错误:
使用bring-add lists查看可用清单及其准确名称。
规格解析:
只有最后一个词看起来像数量时才会被视为规格。红洋葱保持为一个物品,但红洋葱 3个会拆分为物品红洋葱和规格3个。
脚本中的交互模式:
在脚本中使用--no-input参数,以便明确失败,而不是等待输入而挂起。
实现说明
- - 使用node-bring-api的batchUpdateList() API
- 需要Node.js 18.0.0+
- 数据输出到标准输出,进度/错误输出到标准错误
- 提供JSON模式用于自动化
- 仅当标准输入是终端时启用交互模式