Skip to content

Commit fb2a145

Browse files
authored
feat(xueqiu): make primary args positional (#213)
- search: query → positional - stock: symbol → positional - earnings-date: symbol → positional - Fix build-manifest scanYaml to preserve positional field Usage: opencli xueqiu search '茅台' opencli xueqiu stock SH600519 opencli xueqiu earnings-date SH600519
1 parent bd274ce commit fb2a145

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/build-manifest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ function scanYaml(filePath: string, site: string): ManifestEntry | null {
206206
type: argDef?.type ?? 'str',
207207
default: argDef?.default,
208208
required: argDef?.required ?? false,
209+
positional: argDef?.positional === true || undefined,
209210
help: argDef?.description ?? argDef?.help ?? '',
210211
choices: argDef?.choices,
211212
});

src/clis/xueqiu/earnings-date.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ browser: true
66

77
args:
88
symbol:
9+
positional: true
910
type: str
11+
required: true
1012
description: 股票代码,如 SH600519、SZ000858、00700
1113
next:
1214
type: bool

src/clis/xueqiu/search.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ browser: true
66

77
args:
88
query:
9+
positional: true
910
type: str
11+
required: true
1012
description: 搜索关键词,如 茅台、AAPL、腾讯
1113
limit:
1214
type: int
@@ -19,7 +21,6 @@ pipeline:
1921
(async () => {
2022
const query = ${{ args.query | json }};
2123
const count = ${{ args.limit }};
22-
if (!query) throw new Error('Missing argument: query');
2324
const resp = await fetch(`https://xueqiu.com/stock/search.json?code=${encodeURIComponent(query)}&size=${count}`, {credentials: 'include'});
2425
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' Hint: Not logged in?');
2526
const d = await resp.json();

src/clis/xueqiu/stock.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ browser: true
66

77
args:
88
symbol:
9+
positional: true
910
type: str
11+
required: true
1012
description: 股票代码,如 SH600519、SZ000858、AAPL、00700
1113

1214
pipeline:

0 commit comments

Comments
 (0)