From ceacc2675dc2c90109a7a8e21c36eb2ea577cb57 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 06:51:29 +0000 Subject: [PATCH] refactor(auto-reply): dedupe command arg formatting --- src/auto-reply/commands-args.ts | 35 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/auto-reply/commands-args.ts b/src/auto-reply/commands-args.ts index cd617071b6..cc1fa54118 100644 --- a/src/auto-reply/commands-args.ts +++ b/src/auto-reply/commands-args.ts @@ -29,22 +29,11 @@ const formatConfigArgs: CommandArgsFormatter = (values) => { if (!action) { return undefined; } + const rest = formatSetUnsetArgAction(action, { path, value }); if (action === "show" || action === "get") { return path ? `${action} ${path}` : action; } - if (action === "unset") { - return path ? `${action} ${path}` : action; - } - if (action === "set") { - if (!path) { - return action; - } - if (!value) { - return `${action} ${path}`; - } - return `${action} ${path}=${value}`; - } - return action; + return rest; }; const formatDebugArgs: CommandArgsFormatter = (values) => { @@ -54,23 +43,31 @@ const formatDebugArgs: CommandArgsFormatter = (values) => { if (!action) { return undefined; } + const rest = formatSetUnsetArgAction(action, { path, value }); if (action === "show" || action === "reset") { return action; } + return rest; +}; + +function formatSetUnsetArgAction( + action: string, + params: { path: string | undefined; value: string | undefined }, +): string { if (action === "unset") { - return path ? `${action} ${path}` : action; + return params.path ? `${action} ${params.path}` : action; } if (action === "set") { - if (!path) { + if (!params.path) { return action; } - if (!value) { - return `${action} ${path}`; + if (!params.value) { + return `${action} ${params.path}`; } - return `${action} ${path}=${value}`; + return `${action} ${params.path}=${params.value}`; } return action; -}; +} const formatQueueArgs: CommandArgsFormatter = (values) => { const mode = normalizeArgValue(values.mode);