From 52b0c6252dfb92b8c5988403cb14f6d182438ffa Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 24 Nov 2025 12:07:55 +0100 Subject: [PATCH] Add -y/--yes to auto-confirm prompts; verbose keeps showing command output --- src/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.ts b/src/index.ts index 3c423f811..c3dd97f1f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,6 +20,7 @@ dotenv.config({ quiet: true }); const program = new Command(); let globalVerbose = false; +let globalYes = false; function setVerbose(v: boolean) { globalVerbose = v; @@ -29,12 +30,17 @@ function logVerbose(message: string) { if (globalVerbose) console.log(chalk.gray(message)); } +function setYes(v: boolean) { + globalYes = v; +} + type AuthMode = | { accountSid: string; authToken: string } | { accountSid: string; apiKey: string; apiSecret: string }; type GlobalOptions = { verbose: boolean; + yes?: boolean; }; type EnvConfig = { @@ -120,6 +126,7 @@ async function ensureBinary(name: string): Promise { } async function promptYesNo(question: string, defaultYes = false): Promise { + if (globalYes) return true; const rl = readline.createInterface({ input, output }); const suffix = defaultYes ? ' [Y/n] ' : ' [y/N] '; const answer = (await rl.question(`${question}${suffix}`)).trim().toLowerCase(); @@ -593,6 +600,7 @@ program .option('-r, --reply ', 'Optional auto-reply text') .option('--path ', 'Webhook path', '/webhook/whatsapp') .option('--verbose', 'Log inbound and auto-replies', false) + .option('-y, --yes', 'Auto-confirm prompts when possible', false) .addHelpText( 'after', ` @@ -607,6 +615,7 @@ With Tailscale: ) .action(async (opts) => { setVerbose(Boolean(opts.verbose)); + setYes(Boolean(opts.yes)); const port = Number.parseInt(opts.port, 10); if (Number.isNaN(port) || port <= 0 || port >= 65536) { console.error('Port must be between 1 and 65535'); @@ -621,8 +630,10 @@ program .option('-p, --port ', 'Port to listen on', '42873') .option('--path ', 'Webhook path', '/webhook/whatsapp') .option('--verbose', 'Verbose logging during setup/webhook', false) + .option('-y, --yes', 'Auto-confirm prompts when possible', false) .action(async (opts) => { setVerbose(Boolean(opts.verbose)); + setYes(Boolean(opts.yes)); const port = Number.parseInt(opts.port, 10); if (Number.isNaN(port) || port <= 0 || port >= 65536) { console.error('Port must be between 1 and 65535');