From 8eecf97cc5a60f795b1eb6fd705c5484e1353913 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 02:39:55 +0000 Subject: [PATCH] refactor(cli): share gmail webhook option parsing --- src/cli/webhooks-cli.ts | 54 +++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/src/cli/webhooks-cli.ts b/src/cli/webhooks-cli.ts index c9c49a2b1b..c5a551afd8 100644 --- a/src/cli/webhooks-cli.ts +++ b/src/cli/webhooks-cli.ts @@ -110,32 +110,54 @@ function parseGmailSetupOptions(raw: Record): GmailSetupOptions if (!account) { throw new Error("--account is required"); } + const common = parseGmailCommonOptions(raw); return { account, project: stringOption(raw.project), - topic: stringOption(raw.topic), - subscription: stringOption(raw.subscription), - label: stringOption(raw.label), - hookUrl: stringOption(raw.hookUrl), - hookToken: stringOption(raw.hookToken), - pushToken: stringOption(raw.pushToken), - bind: stringOption(raw.bind), - port: numberOption(raw.port), - path: stringOption(raw.path), - includeBody: booleanOption(raw.includeBody), - maxBytes: numberOption(raw.maxBytes), - renewEveryMinutes: numberOption(raw.renewMinutes), - tailscale: stringOption(raw.tailscale) as GmailSetupOptions["tailscale"], - tailscalePath: stringOption(raw.tailscalePath), - tailscaleTarget: stringOption(raw.tailscaleTarget), + topic: common.topic, + subscription: common.subscription, + label: common.label, + hookUrl: common.hookUrl, + hookToken: common.hookToken, + pushToken: common.pushToken, + bind: common.bind, + port: common.port, + path: common.path, + includeBody: common.includeBody, + maxBytes: common.maxBytes, + renewEveryMinutes: common.renewEveryMinutes, + tailscale: common.tailscaleRaw as GmailSetupOptions["tailscale"], + tailscalePath: common.tailscalePath, + tailscaleTarget: common.tailscaleTarget, pushEndpoint: stringOption(raw.pushEndpoint), json: Boolean(raw.json), }; } function parseGmailRunOptions(raw: Record): GmailRunOptions { + const common = parseGmailCommonOptions(raw); return { account: stringOption(raw.account), + topic: common.topic, + subscription: common.subscription, + label: common.label, + hookUrl: common.hookUrl, + hookToken: common.hookToken, + pushToken: common.pushToken, + bind: common.bind, + port: common.port, + path: common.path, + includeBody: common.includeBody, + maxBytes: common.maxBytes, + renewEveryMinutes: common.renewEveryMinutes, + tailscale: common.tailscaleRaw as GmailRunOptions["tailscale"], + tailscalePath: common.tailscalePath, + tailscaleTarget: common.tailscaleTarget, + }; +} + +function parseGmailCommonOptions(raw: Record) { + return { topic: stringOption(raw.topic), subscription: stringOption(raw.subscription), label: stringOption(raw.label), @@ -148,7 +170,7 @@ function parseGmailRunOptions(raw: Record): GmailRunOptions { includeBody: booleanOption(raw.includeBody), maxBytes: numberOption(raw.maxBytes), renewEveryMinutes: numberOption(raw.renewMinutes), - tailscale: stringOption(raw.tailscale) as GmailRunOptions["tailscale"], + tailscaleRaw: stringOption(raw.tailscale), tailscalePath: stringOption(raw.tailscalePath), tailscaleTarget: stringOption(raw.tailscaleTarget), };