Skip to content

Commit

Permalink
fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Apr 4, 2024
1 parent 6d27011 commit 7a3dd3c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
15 changes: 14 additions & 1 deletion apps/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
### Weibo-archiver CLI 版本

运行方式:`node weibo-archiver.mjs -h`
运行方式:`node weibo-archiver.mjs 参数`

首次运行将生成配置文件 `~/.config/weibo-archiver.json` (Windows 下 `~` 代指 `C:\Users\{你的用户名}`

具体参数如下

```bash
USAGE weibo-archiver [OPTIONS]

OPTIONS

--uid 微博用户的 uid
--savePath="~\weibo-archiver" 微博数据的保存路径
```
2 changes: 2 additions & 0 deletions apps/cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const config = await loadConfig<Config>({

effect(async () => {
await saveConfig(config)
}, {
lazy: true,
})

if (!existsSync(configFile))
Expand Down
15 changes: 7 additions & 8 deletions apps/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { defineCommand, runMain } from 'citty'
import { consola } from 'consola'
import { parseText, userInfo } from '@weibo-archiver/shared'
import { userInfo } from '@weibo-archiver/shared'

import config from './config'

Expand All @@ -11,15 +11,14 @@ import config from './config'
*/
const main = defineCommand({
meta: {
name: 'Weibo archiver',
name: 'weibo-archiver',
version: '0.3.11',
description: 'Weibo archiver 命令行版本',
},
args: {
name: {
uid: {
type: 'string',
description: 'Your name',
required: true,
description: '微博用户的 uid',
},
savePath: {
type: 'string',
Expand All @@ -28,12 +27,12 @@ const main = defineCommand({
},
},
async run({ args }) {
consola.info(`Hello`, parseText(args.name))
config.savePath = args.savePath
config.uid = args.uid || config.uid

consola.info('已加载的配置:', config)
consola.info('已加载的配置:', JSON.stringify(config, null, 2))

const user = await userInfo({ name: args.name })
const user = await userInfo({ id: config.uid })
console.log(user)
},
})
Expand Down
17 changes: 1 addition & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a3dd3c

Please sign in to comment.