@acanthis-dec/cli 0.0.0-stage → 0.1.0
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/LICENSE +7 -0
- package/README.md +115 -2
- package/README.zh-CN.md +116 -0
- package/dist/index.mjs +6116 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 ConstasJ
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @acanthis-dec/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文文档](./README.zh-CN.md) | [Workspace README](../../README.md)
|
|
4
|
+
|
|
5
|
+
Dual-mode EPUB 3.0 export CLI (`acanthis`) for Acanthis. It connects to an `@acanthis-dec/api-server` instance to browse, search, inspect, and export light novels into standard EPUB 3.0 ebooks (both per-volume split mode and multi-volume merged mode) via either scriptable CLI subcommands or an interactive terminal wizard.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Option 1: npm / Node.js
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @acanthis-dec/cli
|
|
13
|
+
# or run without installing globally
|
|
14
|
+
npx @acanthis-dec/cli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Option 2: Standalone Binary (GitHub Releases / Homebrew / WinGet)
|
|
18
|
+
|
|
19
|
+
Download the precompiled binary archive for your platform (`Windows x64`, `Linux x64/arm64`, `macOS arm64/x64`) from GitHub Releases, verify its checksum against `SHA256SUMS.txt`, or install via WinGet / Homebrew when published to your tap/manifest repository.
|
|
20
|
+
|
|
21
|
+
## Usage Modes
|
|
22
|
+
|
|
23
|
+
### Interactive Wizard (TTY)
|
|
24
|
+
|
|
25
|
+
Running `acanthis` with no arguments in an interactive terminal launches the guided wizard:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
acanthis
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The wizard probes server connectivity (prompting for a new `serverUrl` or token if unreachable), lets you select a novel source, browse the cached library, search by keyword, or enter a novel ID/URL directly, multiselect target volumes, pick `split` or `merged` mode, and track export progress.
|
|
32
|
+
|
|
33
|
+
> Running `acanthis` with no subcommand in a **non-TTY** environment (such as CI or piped stdin/stdout) prints help and exits immediately with exit code `1` without blocking.
|
|
34
|
+
|
|
35
|
+
### Subcommands
|
|
36
|
+
|
|
37
|
+
#### `acanthis export <novelIdOrUrl>`
|
|
38
|
+
|
|
39
|
+
Export a novel (by numeric ID or URL such as `https://www.linovelib.com/novel/3590.html`) to `.epub` file(s).
|
|
40
|
+
|
|
41
|
+
| Flag | Alias | Default | Description |
|
|
42
|
+
| ------------------------ | ----- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `--server <url>` | `-s` | Config / `http://localhost:5301` | Acanthis API server base URL |
|
|
44
|
+
| `--source <platform>` | — | Config / `linovelib` | Novel source identifier |
|
|
45
|
+
| `--token <token>` | `-t` | Config / unset | Optional Bearer auth token |
|
|
46
|
+
| `--output <dir>` | `-o` | Config / `.` | Output directory |
|
|
47
|
+
| `--mode <split\|merged>` | `-m` | `split` | `split` produces `[Author] Title - Volume.epub` per volume; `merged` produces `[Author] Title.epub` (or `(选集)` when subset selected) |
|
|
48
|
+
| `--merged` | — | `false` | Shortcut overriding `--mode` to `merged` |
|
|
49
|
+
| `--volumes <spec>` | `-v` | All volumes | Comma-separated 1-based indices, ranges (e.g. `1,3-5`), or volume IDs |
|
|
50
|
+
| `--no-illustrations` | — | `illustrations = true` | Skip downloading chapter illustrations (covers only; missing images render placeholder text) |
|
|
51
|
+
| `--strict` | — | `false` | Abort with exit code `1` on unresolved `TOBEDETERMINED` chapters or chapter/illustration retry exhaustion (volume cover `404` always falls back gracefully) |
|
|
52
|
+
| `--overwrite` | — | `false` | Overwrite existing `.epub` files instead of skipping |
|
|
53
|
+
| `--json` | — | `false` | Emit only one JSON summary object to `stdout`; all progress and warnings go to `stderr` |
|
|
54
|
+
|
|
55
|
+
#### `acanthis search <keyword>`
|
|
56
|
+
|
|
57
|
+
Search novels on the configured source.
|
|
58
|
+
|
|
59
|
+
- Options: `-s, --server <url>`, `--source <platform>`, `-t, --token <token>`, `--json`
|
|
60
|
+
|
|
61
|
+
#### `acanthis list`
|
|
62
|
+
|
|
63
|
+
List cached novels stored on the API server.
|
|
64
|
+
|
|
65
|
+
- Options: `--page <number>`, `--page-size <number>`, `-s, --server <url>`, `--source <platform>`, `-t, --token <token>`, `--json`
|
|
66
|
+
|
|
67
|
+
#### `acanthis sources`
|
|
68
|
+
|
|
69
|
+
List available novel sources reported by `GET /v1/sources`.
|
|
70
|
+
|
|
71
|
+
- Options: `-s, --server <url>`, `-t, --token <token>`, `--json`
|
|
72
|
+
|
|
73
|
+
#### `acanthis info <novelIdOrUrl>`
|
|
74
|
+
|
|
75
|
+
Display novel metadata, 1-based volume numbers, chapter counts, and unresolved `TOBEDETERMINED` chapter warnings.
|
|
76
|
+
|
|
77
|
+
- Options: `-s, --server <url>`, `--source <platform>`, `-t, --token <token>`, `--json`
|
|
78
|
+
|
|
79
|
+
#### `acanthis config <action> [key] [value]`
|
|
80
|
+
|
|
81
|
+
Manage persistent user configuration.
|
|
82
|
+
|
|
83
|
+
- Actions:
|
|
84
|
+
- `acanthis config path [--json]` — Print the config file path
|
|
85
|
+
- `acanthis config list [--json]` — Show stored and resolved config values
|
|
86
|
+
- `acanthis config get <key> [--json]` — Read a single config key
|
|
87
|
+
- `acanthis config set <key> <value> [--json]` — Atomically update a config key
|
|
88
|
+
- `acanthis config reset [--json]` — Remove the persisted config file
|
|
89
|
+
- Allowed keys: `serverUrl`, `token`, `defaultSource`, `outputDir`
|
|
90
|
+
|
|
91
|
+
## Configuration Precedence & Environment Variables
|
|
92
|
+
|
|
93
|
+
Configuration is resolved in 4 tiers (highest priority first):
|
|
94
|
+
|
|
95
|
+
1. **CLI flags** (`--server`, `--token`, `--source`, `--output`)
|
|
96
|
+
2. **Environment variables** (empty strings are ignored):
|
|
97
|
+
- `ACANTHIS_SERVER_URL`
|
|
98
|
+
- `ACANTHIS_API_TOKEN`
|
|
99
|
+
- `ACANTHIS_SOURCE`
|
|
100
|
+
- `ACANTHIS_OUTPUT_DIR`
|
|
101
|
+
3. **User config file**:
|
|
102
|
+
- Windows: `%APPDATA%\acanthis\config.json`
|
|
103
|
+
- macOS / Linux: `${XDG_CONFIG_HOME:-~/.config}/acanthis/config.json`
|
|
104
|
+
4. **Built-in defaults**:
|
|
105
|
+
- `serverUrl`: `http://localhost:5301`
|
|
106
|
+
- `defaultSource`: `linovelib`
|
|
107
|
+
- `outputDir`: `.`
|
|
108
|
+
- `token`: unset
|
|
109
|
+
|
|
110
|
+
## Exit Codes
|
|
111
|
+
|
|
112
|
+
| Exit Code | Meaning |
|
|
113
|
+
| --------- | -------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `0` | Success |
|
|
115
|
+
| `1` | Runtime, network, authentication (`401`), `--strict` abort, or non-TTY root invocation error |
|
|
116
|
+
| `2` | Invalid CLI arguments, validation failure, or configuration file error (`CliConfigError`) |
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# @acanthis-dec/cli
|
|
2
|
+
|
|
3
|
+
[English README](./README.md) | [工作区 README](../../README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Acanthis 的双模 EPUB 3.0 导出命令行工具(`acanthis`)。通过连接 `@acanthis-dec/api-server` 服务端,支持以可脚本化的子命令或终端交互向导两种方式浏览书库、搜索作品、查看详情并将轻小说导出为标准 EPUB 3.0 电子书(支持按卷拆分与整书合并两种模式)。
|
|
6
|
+
|
|
7
|
+
## 安装方式
|
|
8
|
+
|
|
9
|
+
### 方式一:通过 npm / Node.js 使用
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @acanthis-dec/cli
|
|
13
|
+
# 或免全局安装直接运行
|
|
14
|
+
npx @acanthis-dec/cli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 方式二:单文件二进制(GitHub Releases / Homebrew / WinGet)
|
|
18
|
+
|
|
19
|
+
可从 GitHub Releases 下载对应平台(`Windows x64`、`Linux x64/arm64`、`macOS arm64/x64`)的预编译压缩包并核对 `SHA256SUMS.txt`,或在配置好对应软件源后通过 WinGet / Homebrew 安装。
|
|
20
|
+
|
|
21
|
+
## 使用模式
|
|
22
|
+
|
|
23
|
+
### 交互式向导(TTY 终端)
|
|
24
|
+
|
|
25
|
+
在交互式终端中不带参数直接运行 `acanthis` 即可启动向导:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
acanthis
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
向导会自动探测服务端连通性(不可达时引导输入新的 `serverUrl` 或访问令牌并可选保存),支持选择书源、浏览服务端已缓存书库、关键词搜索或直接输入作品 ID/URL,随后多选目标分卷、选择 `split` / `merged` 模式并实时展示导出进度。
|
|
32
|
+
|
|
33
|
+
> 在**非 TTY 环境**(如 CI 流水线或管道重定向)下不带子命令调用 `acanthis` 时,会直接打印帮助并以退出码 `1` 退出,绝不挂起等待输入。
|
|
34
|
+
|
|
35
|
+
### 子命令一览
|
|
36
|
+
|
|
37
|
+
#### `acanthis export <novelIdOrUrl>`
|
|
38
|
+
|
|
39
|
+
按作品数字 ID 或作品页面链接(如 `https://www.linovelib.com/novel/3590.html`)导出 `.epub` 文件。
|
|
40
|
+
|
|
41
|
+
| 参数 | 短参数 | 默认值 | 说明 |
|
|
42
|
+
| ------------------------ | ------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `--server <url>` | `-s` | 配置值 / `http://localhost:5301` | Acanthis API 服务端基础地址 |
|
|
44
|
+
| `--source <platform>` | — | 配置值 / `linovelib` | 书源标识 |
|
|
45
|
+
| `--token <token>` | `-t` | 配置值 / 未设置 | 可选 Bearer 访问令牌 |
|
|
46
|
+
| `--output <dir>` | `-o` | 配置值 / `.` | 导出文件输出目录 |
|
|
47
|
+
| `--mode <split\|merged>` | `-m` | `split` | `split` 按分卷输出 `[作者] 书名 - 分卷名.epub`;`merged` 合并输出 `[作者] 书名.epub`(选定部分分卷时为 `(选集)`) |
|
|
48
|
+
| `--merged` | — | `false` | 快捷开关,等价于 `--mode merged` |
|
|
49
|
+
| `--volumes <spec>` | `-v` | 全部分卷 | 逗号分隔的 1 基卷序号、闭区间(如 `1,3-5`)或分卷 ID |
|
|
50
|
+
| `--no-illustrations` | — | `illustrations = true` | 跳过章节插图下载(仅保留封面,正文中缺失插图将替换为占位提示) |
|
|
51
|
+
| `--strict` | — | `false` | 遇到未决 `TOBEDETERMINED` 章节或章节/插图重试耗尽时立即以退出码 `1` 中止(无封面分卷 `404` 始终自动降级容错) |
|
|
52
|
+
| `--overwrite` | — | `false` | 覆盖已存在的同名 `.epub` 文件(默认跳过) |
|
|
53
|
+
| `--json` | — | `false` | 仅向 `stdout` 输出单行结构化 JSON 结果;所有进度与警告均输出至 `stderr` |
|
|
54
|
+
|
|
55
|
+
#### `acanthis search <keyword>`
|
|
56
|
+
|
|
57
|
+
在指定书源上按关键词搜索作品。
|
|
58
|
+
|
|
59
|
+
- 选项:`-s, --server <url>`、`--source <platform>`、`-t, --token <token>`、`--json`
|
|
60
|
+
|
|
61
|
+
#### `acanthis list`
|
|
62
|
+
|
|
63
|
+
分页列出服务端已缓存的书库作品。
|
|
64
|
+
|
|
65
|
+
- 选项:`--page <number>`、`--page-size <number>`、`-s, --server <url>`、`--source <platform>`、`-t, --token <token>`、`--json`
|
|
66
|
+
|
|
67
|
+
#### `acanthis sources`
|
|
68
|
+
|
|
69
|
+
调用 `GET /v1/sources` 列出服务端当前可用书源。
|
|
70
|
+
|
|
71
|
+
- 选项:`-s, --server <url>`、`-t, --token <token>`、`--json`
|
|
72
|
+
|
|
73
|
+
#### `acanthis info <novelIdOrUrl>`
|
|
74
|
+
|
|
75
|
+
展示作品元数据、1 基分卷序号、章节数量及未决 `TOBEDETERMINED` 章节警告。
|
|
76
|
+
|
|
77
|
+
- 选项:`-s, --server <url>`、`--source <platform>`、`-t, --token <token>`、`--json`
|
|
78
|
+
|
|
79
|
+
#### `acanthis config <action> [key] [value]`
|
|
80
|
+
|
|
81
|
+
管理本地持久化配置文件。
|
|
82
|
+
|
|
83
|
+
- 支持动作:
|
|
84
|
+
- `acanthis config path [--json]` — 输出配置文件路径
|
|
85
|
+
- `acanthis config list [--json]` — 列出已保存配置与最终生效配置
|
|
86
|
+
- `acanthis config get <key> [--json]` — 读取单个配置项
|
|
87
|
+
- `acanthis config set <key> <value> [--json]` — 原子写入更新配置项
|
|
88
|
+
- `acanthis config reset [--json]` — 删除本地配置文件恢复默认
|
|
89
|
+
- 允许的配置键白名单:`serverUrl`、`token`、`defaultSource`、`outputDir`
|
|
90
|
+
|
|
91
|
+
## 配置优先级与环境变量
|
|
92
|
+
|
|
93
|
+
配置按以下 4 级优先级生效(从高到低):
|
|
94
|
+
|
|
95
|
+
1. **CLI 显式参数**(`--server`、`--token`、`--source`、`--output`)
|
|
96
|
+
2. **环境变量**(空字符串自动忽略):
|
|
97
|
+
- `ACANTHIS_SERVER_URL`
|
|
98
|
+
- `ACANTHIS_API_TOKEN`
|
|
99
|
+
- `ACANTHIS_SOURCE`
|
|
100
|
+
- `ACANTHIS_OUTPUT_DIR`
|
|
101
|
+
3. **用户配置文件**:
|
|
102
|
+
- Windows:`%APPDATA%\acanthis\config.json`
|
|
103
|
+
- macOS / Linux:`${XDG_CONFIG_HOME:-~/.config}/acanthis/config.json`
|
|
104
|
+
4. **内置默认值**:
|
|
105
|
+
- `serverUrl`:`http://localhost:5301`
|
|
106
|
+
- `defaultSource`:`linovelib`
|
|
107
|
+
- `outputDir`:`.`
|
|
108
|
+
- `token`:未设置
|
|
109
|
+
|
|
110
|
+
## 退出码说明
|
|
111
|
+
|
|
112
|
+
| 退出码 | 含义 |
|
|
113
|
+
| ------ | ----------------------------------------------------------------------------- |
|
|
114
|
+
| `0` | 执行成功 |
|
|
115
|
+
| `1` | 运行期错误、网络错误、鉴权失败(`401`)、`--strict` 中止或非 TTY 无子命令调用 |
|
|
116
|
+
| `2` | CLI 参数无效、输入校验失败或配置文件错误(`CliConfigError`) |
|