From 61e8ad38fbf568e837e14ce9935cce8e12f36686 Mon Sep 17 00:00:00 2001 From: Steven Syrek Date: Fri, 24 Apr 2026 08:32:47 +0200 Subject: [PATCH 01/23] refactor(write): hoist lang/style/tone enums to module const Extract validLanguages/validStyles/validTones into module-scope WRITE_LANGUAGES/WRITE_STYLES/WRITE_TONES as const arrays, consumed by both the commander option descriptions (interpolated) and the validator branches. Prevents help-text/validator drift as the accepted language and style sets grow. No behavior change. --- src/cli/commands/register-write.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cli/commands/register-write.ts b/src/cli/commands/register-write.ts index 1437343..2318c6a 100644 --- a/src/cli/commands/register-write.ts +++ b/src/cli/commands/register-write.ts @@ -9,6 +9,10 @@ import { isNoInput } from '../../utils/confirm.js'; import { ValidationError } from '../../utils/errors.js'; import { createWriteCommand, type ServiceDeps } from './service-factory.js'; +const WRITE_LANGUAGES = ['de', 'en', 'en-GB', 'en-US', 'es', 'fr', 'it', 'pt', 'pt-BR', 'pt-PT'] as const; +const WRITE_STYLES = ['default', 'simple', 'business', 'academic', 'casual', 'prefer_simple', 'prefer_business', 'prefer_academic', 'prefer_casual'] as const; +const WRITE_TONES = ['default', 'enthusiastic', 'friendly', 'confident', 'diplomatic', 'prefer_enthusiastic', 'prefer_friendly', 'prefer_confident', 'prefer_diplomatic'] as const; + export function registerWrite( program: Command, deps: Pick, @@ -20,10 +24,10 @@ export function registerWrite( .description('Improve text using DeepL Write API (grammar, style, tone)') .argument('[text]', 'Text to improve, file path, or read from stdin') .optionsGroup('Core Options:') - .option('-l, --lang ', 'Target language: de, en, en-GB, en-US, es, fr, it, pt, pt-BR, pt-PT (auto-detect if omitted)') + .option('-l, --lang ', `Target language: ${WRITE_LANGUAGES.join(', ')} (auto-detect if omitted)`) .option('--to ', 'Alias of --lang — accepts the same language values. Provided for muscle-memory consistency with `deepl translate --to`.') - .option('--style