feihuo-cli 0.0.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 +118 -0
- package/dist/index.js +2 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# feihuo-cli
|
|
2
|
+
|
|
3
|
+
飞伙 CLI,用于在命令行中搜索航班。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g feihuo-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
安装后会获得 `feihuo` 命令:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
feihuo --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 配置 API Key
|
|
18
|
+
|
|
19
|
+
首次使用前需要配置 API Key:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
feihuo config set api-key xxxxxx
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
配置会保存到当前用户目录:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
~/.config/feihuo/config.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
后续请求会自动读取配置,并通过 `Authorization: Bearer <api-key>` 访问服务。
|
|
32
|
+
|
|
33
|
+
## 搜索航班
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
feihuo search-flight --dep "上海" --arr "东京" --dep-date 2026-03-20
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
往返搜索:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
feihuo search-flight --dep "上海" --arr "东京" --dep-date 2026-03-20 --back-date 2026-03-25
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
指定舱位:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
feihuo search-flight --dep "上海" --arr "东京" --dep-date 2026-03-20 --berth-type Y
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
完整示例:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
feihuo search-flight --dep "上海" --arr "东京" --dep-date 2026-03-20 --back-date 2026-03-25 --berth-type Y
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 参数说明
|
|
58
|
+
|
|
59
|
+
### search-flight
|
|
60
|
+
|
|
61
|
+
| 参数 | 必填 | 说明 |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `--dep <dep>` | 是 | 出发地,例如:`上海` |
|
|
64
|
+
| `--arr <arr>` | 是 | 到达地,例如:`东京` |
|
|
65
|
+
| `--dep-date <depDate>` | 是 | 出发日期,格式:`YYYY-MM-DD` |
|
|
66
|
+
| `--back-date <backDate>` | 否 | 返程日期,格式:`YYYY-MM-DD` |
|
|
67
|
+
| `--berth-type <berthType>` | 否 | 舱位等级:`Y` 经济舱,`C` 公务舱,`F` 头等舱 |
|
|
68
|
+
|
|
69
|
+
## 查看帮助
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
feihuo --help
|
|
73
|
+
feihuo search-flight --help
|
|
74
|
+
feihuo config --help
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 本地开发
|
|
78
|
+
|
|
79
|
+
安装依赖:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm install
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
生成 API 客户端:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm run nswag
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
构建 CLI:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm run build
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
本地运行:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
node dist/index.js --help
|
|
101
|
+
node dist/index.js search-flight --dep "上海" --arr "东京" --dep-date 2026-03-20
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 发布
|
|
105
|
+
|
|
106
|
+
发布前请确认已登录 npm:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm login
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
发布:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm publish
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`npm publish` 前会自动执行构建,最终发布的包只包含 `dist` 和本文档。npmjs 页面会自动显示本 `README.md`。
|