Skip to content

Commit

Permalink
fix(core): fix error when using -h with checkArgCount, fix #769
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 13, 2022
1 parent 74caa16 commit bf39c27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/command/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function validate(ctx: Context) {
}
}
}
})
}, true)

// check argv
ctx.before('command/execute', (argv: Argv) => {
Expand Down Expand Up @@ -70,5 +70,5 @@ export default function validate(ctx: Context) {
return sendHint('internal.unknown-option', unknown.join(', '))
}
}
})
}, true)
}
12 changes: 12 additions & 0 deletions plugins/common/help/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,16 @@ describe('Help Command', () => {
await client.shouldReply('help')
await client.shouldNotReply('帮助')
})

it('checkArgCount (#769)', async () => {
const app = new App()
app.plugin(help)
app.plugin(mock)
app.command('test <arg>', { checkArgCount: true }).action(() => 'pass')
await app.start()

const client = app.mock.client('123')
await client.shouldReply('test', '缺少参数,输入帮助以查看用法。')
await client.shouldReply('test -h', 'test <arg>')
})
})

0 comments on commit bf39c27

Please sign in to comment.