From 62332c359c6dbf1b86b0a72d4162ef5533c28dd0 Mon Sep 17 00:00:00 2001 From: Shigma Date: Wed, 7 Aug 2024 10:57:41 +0800 Subject: [PATCH] fix(koishi): cmd.parse() should respect fallback, fix #1437 --- packages/core/src/command/parser.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/command/parser.ts b/packages/core/src/command/parser.ts index 6774b7560..31303ddfb 100644 --- a/packages/core/src/command/parser.ts +++ b/packages/core/src/command/parser.ts @@ -369,8 +369,12 @@ export namespace Argv { return true } - parse(argv: string | Argv, terminator?: string, args: any[] = [], options: Dict = {}): Argv { - if (typeof argv === 'string') argv = Argv.parse(argv, terminator) + parse(argv: string | Argv, terminator?: string): Argv { + if (typeof argv === 'string') { + argv = Argv.parse(argv, terminator) + } + const args = argv.args || [] + const options = { ...argv.options } if (!argv.source && argv.tokens) { argv.source = this.name + ' ' + Argv.stringify(argv)