From 1bf0af08e6be06e896f2c1181cf470072d9ce12d Mon Sep 17 00:00:00 2001 From: stratumadev Date: Fri, 28 Nov 2025 13:30:55 +0100 Subject: [PATCH] fix(args): correct parsing so string options don't treat the next option as a value --- modules/module.app-args.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/module.app-args.ts b/modules/module.app-args.ts index 8d7fcf3..abf63e0 100644 --- a/modules/module.app-args.ts +++ b/modules/module.app-args.ts @@ -252,7 +252,12 @@ const getCommander = (cfg: Record, isGUI: boolean) => { ); if (item.default !== undefined) option.default(item.default); + const optionNames = [...args.map((a) => `--${a.name}`), ...args.map((a) => (a.alias ? `-${a.alias}` : null)).filter(Boolean)]; + option.argParser((value) => { + // Prevent from passing other options als value for option + if (value && typeof value === 'string' && value.startsWith('-') && optionNames.includes(value)) return undefined; + if (item.type === 'boolean') { if (value === undefined) return true; if (value === 'true') return true; @@ -277,6 +282,11 @@ const getCommander = (cfg: Record, isGUI: boolean) => { return Number.isFinite(num) ? num : 0; } + if (item.type === 'string') { + if (value === undefined) return undefined; + return value; + } + if (item.choices && !(isGUI && item.name === 'service')) { if (!item.choices.includes(value)) { console.error(`Invalid value '${value}' for --${item.name}. Allowed: ${item.choices.join(', ')}`);