fix(scripts): reject flag device-pair Telegram values

This commit is contained in:
Vincent Koc
2026-06-21 22:56:45 +02:00
parent 3e1d3c5feb
commit 6823f56d8e
2 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -43,6 +43,10 @@ type DevicePairTelegramArgs = {
const BOOLEAN_FLAGS = new Set(["--help", "-h"]);
const VALUE_FLAGS = new Set(["--account", "-a", "--chat", "-c"]);
function isMissingOptionValue(value: string | undefined): boolean {
return !value || BOOLEAN_FLAGS.has(value) || VALUE_FLAGS.has(value) || value.startsWith("--");
}
function writeStdoutLine(...parts: string[]): void {
process.stdout.write(`${parts.join(" ")}\n`);
}
@@ -84,7 +88,7 @@ function validateArgs(args: readonly string[]): void {
}
if (VALUE_FLAGS.has(arg)) {
const value = args[index + 1];
if (!value || value.startsWith("--")) {
if (isMissingOptionValue(value)) {
throw new CliArgumentError(`${arg} requires a value`);
}
index += 1;