From 8031823424ac79e7172bb370c13d4c4bc0f168d9 Mon Sep 17 00:00:00 2001 From: Sukairo-02 Date: Wed, 10 Jul 2024 14:12:36 +0300 Subject: [PATCH] Optimized command validation --- src/command-core.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command-core.ts b/src/command-core.ts index e2899de..48054d0 100755 --- a/src/command-core.ts +++ b/src/command-core.ts @@ -325,9 +325,7 @@ export const command = < >(command: RawCommand): Command> => { const allNames = command.aliases ? [command.name, ...command.aliases] : [command.name]; - const processedOptions = command.options ? validateOptions(command.options) : undefined; const cmd: Command = clone(command) as any; - if ( ( command).subcommands && command.options && Object.values(command.options).find((opt) => opt._.config.type === 'positional') @@ -336,6 +334,8 @@ export const command = < `Can't define command '${cmd.name}' - command can't have subcommands and positional args at the same time!`, ); } + + const processedOptions = command.options ? validateOptions(command.options) : undefined; cmd.options = processedOptions; cmd.name = cmd.name ?? cmd.aliases?.shift();