diff --git a/packages/plugin-common/src/help.ts b/packages/plugin-common/src/help.ts index 1495a04270..81d1a0a650 100644 --- a/packages/plugin-common/src/help.ts +++ b/packages/plugin-common/src/help.ts @@ -113,15 +113,15 @@ async function showCommandHelp (command: Command, meta: Meta<'message'>, options output.push(command._usage) } - if (command._options.length) { - const options = command._options.filter(option => !option.hidden) - if (options.some(o => o.authority)) { + const _options = command._options.filter(option => !option.hidden) + if (_options.length) { + if (_options.some(o => o.authority)) { output.push('可用的选项有(括号内为额外要求的权限等级):') } else { output.push('可用的选项有:') } - command._options.filter(option => !option.hidden).forEach((option) => { + _options.forEach((option) => { const authority = option.authority ? `(${option.authority}) ` : '' let line = ` ${authority}${option.rawName} ${option.description}` if (option.notUsage && maxUsage !== Infinity) { diff --git a/packages/plugin-common/tests/__snapshots__/help.spec.ts.snap b/packages/plugin-common/tests/__snapshots__/help.spec.ts.snap index ee3f700311..61b23927bb 100644 --- a/packages/plugin-common/tests/__snapshots__/help.spec.ts.snap +++ b/packages/plugin-common/tests/__snapshots__/help.spec.ts.snap @@ -11,9 +11,7 @@ Array [ "bar.baz command with alias and shortcut 中文别名:baz-alias。 -相关全局指令:baz-shortcut。 -可用的选项有: - -h, --help 显示本信息", +相关全局指令:baz-shortcut。", ] `; @@ -22,9 +20,7 @@ Array [ "bar.baz command with alias and shortcut 中文别名:baz-alias。 -相关全局指令:baz-shortcut。 -可用的选项有: - -h, --help 显示本信息", +相关全局指令:baz-shortcut。", ] `; @@ -65,8 +61,6 @@ Array [ "bar command with usage and examples usage text -可用的选项有: - -h, --help 显示本信息 使用示例: example 1 example 2 @@ -82,7 +76,6 @@ command with options 已调用次数:0/100。 距离下次调用还需:0/1 秒。 可用的选项有(括号内为额外要求的权限等级): - -h, --help 显示本信息 (2) -o [value] option(不计入总次数)", ] `; @@ -93,7 +86,6 @@ Array [ 显示帮助信息 相关全局指令:帮助,全局指令。 可用的选项有: - -h, --help 显示本信息 -e, --expand 展开指令列表 -s, --shortcut 查看全局指令列表 可用的子指令有(括号内为对应的最低权限等级,标有星号的表示含有子指令): @@ -107,7 +99,6 @@ Array [ 显示帮助信息 相关全局指令:帮助,全局指令。 可用的选项有: - -h, --help 显示本信息 -e, --expand 展开指令列表 -s, --shortcut 查看全局指令列表 可用的子指令有(括号内为对应的最低权限等级,标有星号的表示含有子指令): @@ -121,7 +112,6 @@ Array [ 显示帮助信息 相关全局指令:帮助,全局指令。 可用的选项有: - -h, --help 显示本信息 -e, --expand 展开指令列表 -s, --shortcut 查看全局指令列表 可用的子指令有(括号内为对应的最低权限等级,标有星号的表示含有子指令): @@ -144,7 +134,6 @@ command with options 已调用次数:1/100。 距离下次调用还需:1/1 秒。 可用的选项有(括号内为额外要求的权限等级): - -h, --help 显示本信息 (2) -o [value] option(不计入总次数)", ] `; @@ -154,7 +143,6 @@ Array [ "foo command with options 可用的选项有(括号内为额外要求的权限等级): - -h, --help 显示本信息 (2) -o [value] option(不计入总次数)", ] `;