Skip to content

Commit

Permalink
chore: update README.md (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW authored Aug 13, 2021
1 parent d41c9b7 commit cb23788
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Koishi v3 的另一大亮点就是拥有官方的网页控制台插件。这个
- [koishi-plugin-cryptocurrency](https://github.com/koishijs/plugin-cryptocurrency): 查看和订阅加密货币的市场价格
- [koishi-plugin-jrrp](https://github.com/idlist/koishi-plugin-jrrp): 今日人品
- [koishi-plugin-rpc](https://github.com/Anillc/koishi-plugin-rpc): 一个为其他插件提供 RPC 的插件
- [koishi-plugin-text-dialogue](https://github.com/koishijs/koishi-plugin-developer/tree/master/packages/plugin-text-dialogue): 支持在 md 文档中和你的 bot 对话

### 社区项目

Expand All @@ -141,6 +142,8 @@ Koishi v3 的另一大亮点就是拥有官方的网页控制台插件。这个
- [hydro-dev/HydroBot](https://github.com/hydro-dev/HydroBot): A Simple QQ Robot
- [Wjghj-Project/Chatbot-SILI](https://github.com/Wjghj-Project/Chatbot-SILI): 「即时通讯软件转接姬」SILI-t137-[Tumita]-Invoke-II@LD(A)
- [idlist/2bot-v3](https://github.com/idlist/2bot-v3): 2bot,一个很 2 的 FFXIV bot
- [koishijs/koishi-plugin-developer](https://github.com/koishijs/koishi-plugin-developer): 使用 monorepo + ts + cli 开发你的 koishi 插件,已集成部分开发辅助功能。
- [koishijs/koishi-bots](https://github.com/koishijs/koishi-bots): 用于部署生产环境的 bot,并集合已有的 koishi bot。

## 使用协议

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/command.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ import { Argv } from 'koishi-core'
declare module 'koishi-core' {
namespace Argv {
interface Domain {
int: number
positive: number
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/koishi-core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export namespace Argv {
names.forEach(name => option.values[name] = config.value)
} else if (!bracket.trim()) {
option.type = 'boolean'
} else if (!option.type && fallbackType === 'string' || fallbackType === 'number') {
} else if (!option.type && (fallbackType === 'string' || fallbackType === 'number')) {
option.type = fallbackType
}

Expand Down
6 changes: 6 additions & 0 deletions packages/koishi-core/tests/parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ describe('Parser API', () => {
cmd = app.command('cmd2 <foo> [bar:text]')
cmd.option('alpha', '-a')
cmd.option('beta', '-b <beta>')
// infer argument type from fallback
cmd.option('gamma', '-c <gamma>', { fallback: 0 })
// define argument type by OptionConfig
cmd.option('delta', '-d <delta>', { type: 'string' })
// define argument type directly (should not be overrode by default)
cmd.option('epsilon', '-e <epsilon:posint>', { fallback: 1 })
})

it('option parser', () => {
Expand All @@ -57,6 +61,8 @@ describe('Parser API', () => {
expect(cmd.parse('--delta')).to.have.shape({ error: '', options: { delta: '' } })
expect(cmd.parse('--delta 1')).to.have.shape({ error: '', options: { delta: '1' } })
expect(cmd.parse('--delta -1')).to.have.shape({ error: '', options: { delta: '-1' } })
expect(cmd.parse('--epsilon awee')).to.have.shape({ error: '选项 epsilon 输入无效,请提供一个正整数。' })
expect(cmd.parse('--epsilon 1.2')).to.have.shape({ error: '选项 epsilon 输入无效,请提供一个正整数。' })
})

it('short alias', () => {
Expand Down

0 comments on commit cb23788

Please sign in to comment.