Skip to content

Commit 0998686

Browse files
betegonclaude
andauthored
refactor(init): use shared YES_FLAG and add -y alias constant (#681)
## Summary Applies the same sharing pattern we use for `DRY_RUN_FLAG`/`DRY_RUN_ALIASES` to `YES_FLAG`. Adds a `YES_ALIASES` constant so non-delete commands can reuse `--yes`/`-y` without inlining. Init overrides the brief to keep its "Non-interactive mode (accept defaults)" wording. Follows #676. ## Changes - Add `YES_ALIASES` export to `mutate-command.ts` (mirrors `DRY_RUN_ALIASES`) - Replace init's inline `--yes` definition with `{ ...YES_FLAG, brief: "..." }` ## Test Plan - `npx tsc --noEmit` passes - `sentry-cli init --help` still shows "Non-interactive mode (accept defaults)" for `--yes` Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 264c632 commit 0998686

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/commands/init.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ import { warmOrgDetection } from "../lib/init/prefetch.js";
2727
import { runWizard } from "../lib/init/wizard-runner.js";
2828
import { validateResourceId } from "../lib/input-validation.js";
2929
import { logger } from "../lib/logger.js";
30-
import { DRY_RUN_ALIASES, DRY_RUN_FLAG } from "../lib/mutate-command.js";
30+
import {
31+
DRY_RUN_ALIASES,
32+
DRY_RUN_FLAG,
33+
YES_ALIASES,
34+
YES_FLAG,
35+
} from "../lib/mutate-command.js";
3136

3237
const log = logger.withTag("init");
3338

@@ -205,11 +210,7 @@ export const initCommand = buildCommand<
205210
],
206211
},
207212
flags: {
208-
yes: {
209-
kind: "boolean",
210-
brief: "Non-interactive mode (accept defaults)",
211-
default: false,
212-
},
213+
yes: { ...YES_FLAG, brief: "Non-interactive mode (accept defaults)" },
213214
"dry-run": DRY_RUN_FLAG,
214215
features: {
215216
kind: "parsed",
@@ -228,7 +229,7 @@ export const initCommand = buildCommand<
228229
},
229230
aliases: {
230231
...DRY_RUN_ALIASES,
231-
y: "yes",
232+
...YES_ALIASES,
232233
t: "team",
233234
},
234235
},

src/lib/mutate-command.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ export const DESTRUCTIVE_ALIASES = {
116116
*/
117117
export const DRY_RUN_ALIASES = { n: "dry-run" } as const;
118118

119+
/**
120+
* Alias map for `--yes` only: `-y` → `--yes`.
121+
*
122+
* Used by non-delete commands that need only the yes flag (not force):
123+
* ```ts
124+
* aliases: { ...YES_ALIASES, t: "team" }
125+
* ```
126+
*/
127+
export const YES_ALIASES = { y: "yes" } as const;
128+
119129
// ---------------------------------------------------------------------------
120130
// Level B: shared utilities
121131
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)