From e0758ef71d2fc2149b6a6a513d7c15e81e53d635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Beteg=C3=B3n?= Date: Tue, 7 Apr 2026 15:43:37 +0200 Subject: [PATCH] refactor(init): use shared YES_FLAG and add -y alias constant Follows the same pattern as DRY_RUN_FLAG/DRY_RUN_ALIASES: adds YES_ALIASES for reuse across non-delete commands that need --yes/-y. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/init.ts | 15 ++++++++------- src/lib/mutate-command.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/commands/init.ts b/src/commands/init.ts index 0588533fd..cdc10b053 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -27,7 +27,12 @@ import { warmOrgDetection } from "../lib/init/prefetch.js"; import { runWizard } from "../lib/init/wizard-runner.js"; import { validateResourceId } from "../lib/input-validation.js"; import { logger } from "../lib/logger.js"; -import { DRY_RUN_ALIASES, DRY_RUN_FLAG } from "../lib/mutate-command.js"; +import { + DRY_RUN_ALIASES, + DRY_RUN_FLAG, + YES_ALIASES, + YES_FLAG, +} from "../lib/mutate-command.js"; const log = logger.withTag("init"); @@ -205,11 +210,7 @@ export const initCommand = buildCommand< ], }, flags: { - yes: { - kind: "boolean", - brief: "Non-interactive mode (accept defaults)", - default: false, - }, + yes: { ...YES_FLAG, brief: "Non-interactive mode (accept defaults)" }, "dry-run": DRY_RUN_FLAG, features: { kind: "parsed", @@ -228,7 +229,7 @@ export const initCommand = buildCommand< }, aliases: { ...DRY_RUN_ALIASES, - y: "yes", + ...YES_ALIASES, t: "team", }, }, diff --git a/src/lib/mutate-command.ts b/src/lib/mutate-command.ts index 0abc58226..976f2890f 100644 --- a/src/lib/mutate-command.ts +++ b/src/lib/mutate-command.ts @@ -116,6 +116,16 @@ export const DESTRUCTIVE_ALIASES = { */ export const DRY_RUN_ALIASES = { n: "dry-run" } as const; +/** + * Alias map for `--yes` only: `-y` → `--yes`. + * + * Used by non-delete commands that need only the yes flag (not force): + * ```ts + * aliases: { ...YES_ALIASES, t: "team" } + * ``` + */ +export const YES_ALIASES = { y: "yes" } as const; + // --------------------------------------------------------------------------- // Level B: shared utilities // ---------------------------------------------------------------------------