yaf-cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# yaf-cli
|
|
2
|
+
|
|
3
|
+
[English](#english) · [中文](#中文)
|
|
4
|
+
|
|
5
|
+
Command-line client for [yaf](https://github.com/uxgnod/yaf), a self-hosted, flomo-style memo app that runs on Cloudflare Workers.
|
|
6
|
+
|
|
7
|
+
yaf 的命令行客户端。yaf 是一个跑在 Cloudflare Workers 上、可自部署的 flomo 风格笔记应用。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## English
|
|
12
|
+
|
|
13
|
+
> You need your own yaf deployment. This CLI has no built-in server address. See the [yaf repository](https://github.com/uxgnod/yaf) to deploy one.
|
|
14
|
+
|
|
15
|
+
### Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g yaf-cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires Node.js 20 or later. Once installed, the command is `yaf`.
|
|
22
|
+
|
|
23
|
+
### Quick start
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
yaf login --host https://yaf.example.com # confirm in the browser; asks for the address if --host is omitted
|
|
27
|
+
yaf add "Weekly reports could be generated from memos #idea"
|
|
28
|
+
echo "Notes from a pipe #inbox" | yaf add
|
|
29
|
+
yaf search "weekly report"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Commands
|
|
33
|
+
|
|
34
|
+
| Command | Description |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `yaf login [--host <url>]` | Sign in through the browser (device code). The address is saved after the first login. |
|
|
37
|
+
| `yaf add [text]` | Create a memo. Reads stdin when no text is given. `#tags` (including `#a/b`) are recognized. |
|
|
38
|
+
| `yaf search [query] [-t <tag>] [-n <limit>] [--json]` | Search memos (hybrid keyword + semantic). Default limit is 20. |
|
|
39
|
+
| `yaf tags` | List tags with counts. |
|
|
40
|
+
| `yaf export [-t <tag>] [-f md\|json] [-o <file>]` | Export memos as Markdown (default) or JSON, to stdout or a file. |
|
|
41
|
+
| `yaf whoami` | Show the signed-in account and server. |
|
|
42
|
+
| `yaf logout` | Delete the locally saved token. |
|
|
43
|
+
|
|
44
|
+
### Configuration
|
|
45
|
+
|
|
46
|
+
- The server address and token are stored in `~/.config/yaf/config.json` (file mode `600`). `XDG_CONFIG_HOME` is respected.
|
|
47
|
+
- `YAF_HOST` and `YAF_TOKEN` override the config file, which is useful for scripts and CI. Create a token in **Settings › API Token** of your yaf instance.
|
|
48
|
+
- `yaf logout` only deletes the local copy. To revoke a token, use **Settings › API Token**.
|
|
49
|
+
- Memos created by the CLI are marked with a CLI source icon. To tag them automatically, turn on **Settings › API Token › Auto tags › CLI**.
|
|
50
|
+
|
|
51
|
+
Messages printed by the CLI are currently in Chinese.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 中文
|
|
56
|
+
|
|
57
|
+
> 需要先有自己部署的 yaf 服务,CLI 不内置任何服务地址。部署方法见 [yaf 仓库](https://github.com/uxgnod/yaf)。
|
|
58
|
+
|
|
59
|
+
### 安装
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npm install -g yaf-cli
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
需要 Node.js 20 或更高版本。安装后使用的命令是 `yaf`。
|
|
66
|
+
|
|
67
|
+
### 快速开始
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
yaf login --host https://yaf.example.com # 在浏览器里确认;不带 --host 时会询问地址
|
|
71
|
+
yaf add "周报可以直接从 memo 里生成 #想法"
|
|
72
|
+
echo "从管道写入 #inbox" | yaf add
|
|
73
|
+
yaf search 周报
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 命令
|
|
77
|
+
|
|
78
|
+
| 命令 | 说明 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `yaf login [--host <url>]` | 在浏览器里授权登录(设备码)。地址在第一次登录后保存。 |
|
|
81
|
+
| `yaf add [内容]` | 新增 memo;不带内容时读取标准输入。支持 `#标签` 和层级 `#a/b`。 |
|
|
82
|
+
| `yaf search [关键词] [-t <标签>] [-n <条数>] [--json]` | 搜索 memo(关键词 + 语义混合检索),默认 20 条。 |
|
|
83
|
+
| `yaf tags` | 列出标签和数量。 |
|
|
84
|
+
| `yaf export [-t <标签>] [-f md\|json] [-o <文件>]` | 导出为 Markdown(默认)或 JSON,输出到终端或文件。 |
|
|
85
|
+
| `yaf whoami` | 查看当前登录的账号和服务地址。 |
|
|
86
|
+
| `yaf logout` | 删除本地保存的 Token。 |
|
|
87
|
+
|
|
88
|
+
### 配置
|
|
89
|
+
|
|
90
|
+
- 服务地址和 Token 保存在 `~/.config/yaf/config.json`(权限 `600`),支持 `XDG_CONFIG_HOME`。
|
|
91
|
+
- 环境变量 `YAF_HOST`、`YAF_TOKEN` 优先于配置文件,适合脚本和 CI。Token 在 yaf 的「设置 › API Token」里创建。
|
|
92
|
+
- `yaf logout` 只删除本地副本。要让 Token 失效,请在「设置 › API Token」里撤销。
|
|
93
|
+
- CLI 写入的 memo 会显示 CLI 来源图标。想自动加标签,在「设置 › API Token › 自动标签 › CLI」里开启。
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -242,7 +242,7 @@ const commands = {
|
|
|
242
242
|
if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h")
|
|
243
243
|
console.log(HELP);
|
|
244
244
|
else if (cmd === "--version" || cmd === "-v")
|
|
245
|
-
console.log("
|
|
245
|
+
console.log(JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8")).version);
|
|
246
246
|
else if (!commands[cmd])
|
|
247
247
|
die(`未知命令 ${cmd}\n\n${HELP}`);
|
|
248
248
|
else
|