From 15e8f67296ea19d8e7f248304721e4572b411ccc Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 11:03:57 +0530 Subject: [PATCH 1/4] CL-8827 | Drop environment description from env:create, env:update and env:get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Launch UI never shows or edits an environment's description, and the CLI's handling of it was broken: `env:update --description ""` was treated as no flag (exit 2 alone, silently dropped when combined), and the interactive Description prompt could neither set an empty value nor clear an existing one. Match the UI instead of fixing a field nobody else exposes. - env:create and env:update no longer declare --description; passing it is oclif's unknown-flag error, and no description is sent to the API. - env:update's "Pass at least one of ..." list and its interactive field checklist no longer offer it. - env:get no longer prints a DESCRIPTION row. - Remove ENVIRONMENT_DESCRIPTION_MAX_LENGTH and description from the environment types. Project description is untouched. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/commands/launch/env/create.test.ts | 20 +++--------------- src/commands/launch/env/create.ts | 2 -- src/commands/launch/env/get.test.ts | 5 +++-- src/commands/launch/env/update.test.ts | 6 +----- src/commands/launch/env/update.ts | 2 -- src/environments/environment.create.test.ts | 3 +-- src/environments/environment.create.ts | 5 ----- src/environments/environment.inputs.ts | 3 --- .../environment.presenter.test.ts | 3 --- src/environments/environment.presenter.ts | 1 - .../environment.update.prompt.test.ts | 21 +++---------------- src/environments/environment.update.prompt.ts | 8 ------- src/environments/environment.update.test.ts | 4 +--- src/environments/environment.update.ts | 3 --- src/environments/types.ts | 3 --- 15 files changed, 12 insertions(+), 77 deletions(-) diff --git a/src/commands/launch/env/create.test.ts b/src/commands/launch/env/create.test.ts index 95fcc68b..a0115808 100644 --- a/src/commands/launch/env/create.test.ts +++ b/src/commands/launch/env/create.test.ts @@ -1,8 +1,5 @@ import { UsageError } from '../../../core/errors'; -import { - ENVIRONMENT_DESCRIPTION_MAX_LENGTH, - ENVIRONMENT_NAME_MAX_LENGTH, -} from '../../../environments/environment.inputs'; +import { ENVIRONMENT_NAME_MAX_LENGTH } from '../../../environments/environment.inputs'; import { catalog, resolution } from '../../../resources'; import { DEPLOYMENT_WAIT_TIMEOUT_MS } from '../../../deployments/deployment.watcher'; import { EnvironmentCreator } from '../../../environments/environment.create'; @@ -37,7 +34,6 @@ describe('launch:env:create', () => { await commandUnderTest({ name: 'staging', - description: 'pre-release', branch: 'develop', framework: 'NEXTJS', 'build-cmd': 'npm run build', @@ -59,7 +55,6 @@ describe('launch:env:create', () => { dataDir: '/tmp/site', configPath: '/tmp/site/.cs-launch.json', name: 'staging', - description: 'pre-release', branch: 'develop', framework: 'NEXTJS', buildCmd: 'npm run build', @@ -89,7 +84,6 @@ describe('launch:env:create', () => { org: { required: true }, project: { required: true }, name: {}, - description: {}, branch: {}, framework: {}, 'build-cmd': {}, @@ -107,28 +101,20 @@ describe('launch:env:create', () => { expect(EnvironmentsCreate.rules).toEqual([serverCommandFrameworkGate, aliasRequiresFromStack]); }); - it('describes --name and --description as the environment its own, leaving the project wording alone', () => { + it('describes --name as the environment its own, leaving the project wording alone', () => { expect(EnvironmentsCreate.flags.name.description).toBe('Environment name (200 characters or fewer)'); - expect(EnvironmentsCreate.flags.description.description).toBe('Environment description (255 characters or fewer)'); expect(catalog.name.description).toBe('Project name (200 characters or fewer)'); expect(catalog.description.description).toBe('Project description (255 characters or fewer)'); expect(EnvironmentsCreate.flags.org).toBe(catalog.org); }); - it('states in --help the same limits the shared --name and --description specs enforce', async () => { + it('states in --help the same limit the shared --name spec enforces', async () => { const nameSpec = resolution.name as { normalize(value: string): Promise }; - const descriptionSpec = resolution.description as { normalize(value: string): Promise }; await expect(nameSpec.normalize('n'.repeat(ENVIRONMENT_NAME_MAX_LENGTH))).resolves.toHaveLength( ENVIRONMENT_NAME_MAX_LENGTH, ); await expect(nameSpec.normalize('n'.repeat(ENVIRONMENT_NAME_MAX_LENGTH + 1))).rejects.toThrow(UsageError); - await expect(descriptionSpec.normalize('d'.repeat(ENVIRONMENT_DESCRIPTION_MAX_LENGTH))).resolves.toHaveLength( - ENVIRONMENT_DESCRIPTION_MAX_LENGTH, - ); - await expect(descriptionSpec.normalize('d'.repeat(ENVIRONMENT_DESCRIPTION_MAX_LENGTH + 1))).rejects.toThrow( - UsageError, - ); }); }); diff --git a/src/commands/launch/env/create.ts b/src/commands/launch/env/create.ts index 1c8e9bed..f4bd2fa4 100644 --- a/src/commands/launch/env/create.ts +++ b/src/commands/launch/env/create.ts @@ -9,7 +9,6 @@ const createInputs = inputs({ org: { required: true }, project: { required: true }, name: {}, - description: {}, branch: {}, framework: {}, 'build-cmd': {}, @@ -49,7 +48,6 @@ export default class EnvironmentsCreate extends LaunchCommand { expect(lines[1]).toBe('│ FIELD │ VALUE │'); expect(lines[3]).toBe('│ ENVIRONMENT UID │ env1 │'); expect(lines[5]).toBe('│ NAME │ production │'); - expect(lines).toHaveLength(39); + expect(lines).toHaveLength(37); + expect(lines.join('\n')).not.toContain('DESCRIPTION'); }); it('leaves the branch row out for an environment of a file-upload project', async () => { @@ -53,7 +54,7 @@ describe('launch:env:get', () => { await command.run(); expect(lines.some((line) => line.includes('BRANCH'))).toBe(false); - expect(lines).toHaveLength(37); + expect(lines).toHaveLength(35); }); it('propagates a failed lookup', async () => { diff --git a/src/commands/launch/env/update.test.ts b/src/commands/launch/env/update.test.ts index a7e65b23..95a42c2f 100644 --- a/src/commands/launch/env/update.test.ts +++ b/src/commands/launch/env/update.test.ts @@ -9,7 +9,6 @@ const RESOLVED = { project: 'proj1', env: 'env1', name: 'renamed', - description: 'the live site', branch: 'release', framework: 'NUXT', 'build-cmd': 'npm run build', @@ -56,7 +55,6 @@ describe('launch:env:update', () => { project: 'proj1', environment: 'env1', name: 'renamed', - description: 'the live site', branch: 'release', framework: 'NUXT', buildCmd: 'npm run build', @@ -102,7 +100,6 @@ describe('launch:env:update', () => { 'project', 'env', 'name', - 'description', 'branch', 'framework', 'build-cmd', @@ -125,9 +122,8 @@ describe('launch:env:update', () => { expect(EnvironmentsUpdate.rules).toEqual([serverCommandFrameworkGate]); }); - it('describes --name and --description as the environment its own, leaving the project wording alone', () => { + it('describes --name as the environment its own, leaving the project wording alone', () => { expect(EnvironmentsUpdate.flags.name.description).toBe('Environment name (200 characters or fewer)'); - expect(EnvironmentsUpdate.flags.description.description).toBe('Environment description (255 characters or fewer)'); expect(catalog.name.description).toBe('Project name (200 characters or fewer)'); expect(catalog.description.description).toBe('Project description (255 characters or fewer)'); expect(EnvironmentsUpdate.flags.org).toBe(catalog.org); diff --git a/src/commands/launch/env/update.ts b/src/commands/launch/env/update.ts index 1da321e2..6d283b7f 100644 --- a/src/commands/launch/env/update.ts +++ b/src/commands/launch/env/update.ts @@ -9,7 +9,6 @@ const updateInputs = inputs({ project: { required: true }, env: { required: true }, name: {}, - description: {}, branch: {}, framework: {}, 'build-cmd': {}, @@ -53,7 +52,6 @@ export default class EnvironmentsUpdate extends LaunchCommand { it('creates a GitHub environment and follows its first deployment, ending on the live announcement', async () => { const { creator, calls, lines, created } = creatorUnderTest(); - await creator.create(request({ description: 'pre-release', csAuth: 'disable' })); + await creator.create(request({ csAuth: 'disable' })); expect(calls).toEqual([ 'project {"org":"org1","project":"proj1"}', @@ -169,7 +169,6 @@ describe('EnvironmentCreator', () => { project: 'proj1', input: { name: 'staging', - description: 'pre-release', gitBranch: 'develop', buildCommand: 'npm run build', outputDirectory: './.next', diff --git a/src/environments/environment.create.ts b/src/environments/environment.create.ts index 4e4bd4fb..8827a8b6 100644 --- a/src/environments/environment.create.ts +++ b/src/environments/environment.create.ts @@ -27,7 +27,6 @@ export interface EnvironmentCreateRequest extends EnvironmentRequest { dataDir: string; configPath: string; name?: string; - description?: string; branch?: string; autoDeploy?: ToggleValue; } @@ -79,10 +78,6 @@ export class EnvironmentCreator { const input = await new EnvironmentBuilder(this.services).build(request, name, source, request.autoDeploy); - if (request.description !== undefined) { - input.description = request.description; - } - const environment = await this.services.api.environments.create({ org, project, input }); this.services.ux.print(environmentCreatedLine(this.services.outputIsTTY === true)); diff --git a/src/environments/environment.inputs.ts b/src/environments/environment.inputs.ts index 5c482469..562cc598 100644 --- a/src/environments/environment.inputs.ts +++ b/src/environments/environment.inputs.ts @@ -12,11 +12,8 @@ import { FRAMEWORK_CHOICES, FRAMEWORK_PRESET_BY_LABEL, SERVER_COMMAND_FRAMEWORKS export const ENVIRONMENT_NAME_MAX_LENGTH = 200; -export const ENVIRONMENT_DESCRIPTION_MAX_LENGTH = 255; - const ENVIRONMENT_WORDING: Record = { name: `Environment name (${ENVIRONMENT_NAME_MAX_LENGTH} characters or fewer)`, - description: `Environment description (${ENVIRONMENT_DESCRIPTION_MAX_LENGTH} characters or fewer)`, }; export function withEnvironmentWording>(flags: F): F { diff --git a/src/environments/environment.presenter.test.ts b/src/environments/environment.presenter.test.ts index bb276695..bb107d08 100644 --- a/src/environments/environment.presenter.test.ts +++ b/src/environments/environment.presenter.test.ts @@ -13,7 +13,6 @@ import { const FULL = { uid: 'e1', name: 'production', - description: 'the live site', domains: [{ url: 'https://a.io' }, {}, { url: ' ' }, { url: 'https://b.io' }], gitBranch: 'main', frameworkPreset: 'NEXTJS', @@ -77,7 +76,6 @@ describe('environmentDetailRows', () => { expect(environmentDetailRows(FULL)).toEqual([ { field: 'ENVIRONMENT UID', value: 'e1' }, { field: 'NAME', value: 'production' }, - { field: 'DESCRIPTION', value: 'the live site' }, { field: 'BRANCH', value: 'main' }, { field: 'FRAMEWORK', value: 'NEXTJS' }, { field: 'BUILD COMMAND', value: 'npm run build' }, @@ -106,7 +104,6 @@ describe('environmentDetailRows', () => { '-', '-', '-', - '-', '0', '-', '-', diff --git a/src/environments/environment.presenter.ts b/src/environments/environment.presenter.ts index bed5ba16..652aa7ce 100644 --- a/src/environments/environment.presenter.ts +++ b/src/environments/environment.presenter.ts @@ -50,7 +50,6 @@ export function environmentDetailRows(environment: Environment, showBranch = tru const rows: DetailRow[] = [ { field: 'ENVIRONMENT UID', value: text(environment.uid) }, { field: 'NAME', value: text(environment.name) }, - { field: 'DESCRIPTION', value: text(environment.description) }, { field: 'BRANCH', value: text(environment.gitBranch) }, { field: 'FRAMEWORK', value: text(environment.frameworkPreset) }, { field: 'BUILD COMMAND', value: text(environment.buildCommand) }, diff --git a/src/environments/environment.update.prompt.test.ts b/src/environments/environment.update.prompt.test.ts index 311488f8..61c29910 100644 --- a/src/environments/environment.update.prompt.test.ts +++ b/src/environments/environment.update.prompt.test.ts @@ -5,7 +5,6 @@ import { SETTINGS_QUESTION, promptForEnvironmentUpdate } from './environment.upd const CURRENT: Environment = { uid: 'env1', name: 'production', - description: 'the live site', gitBranch: 'main', frameworkPreset: 'NEXTJS', buildCommand: 'npm run build', @@ -64,7 +63,6 @@ describe('promptForEnvironmentUpdate', () => { message: SETTINGS_QUESTION, choices: [ { name: 'Name', value: 'name' }, - { name: 'Description', value: 'description' }, { name: 'Branch', value: 'branch' }, { name: 'Framework preset', value: 'framework' }, { name: 'Build command', value: 'buildCmd' }, @@ -90,7 +88,7 @@ describe('promptForEnvironmentUpdate', () => { const offered = (asked[0].choices as { value: string }[]).map((choice) => choice.value); expect(offered).not.toContain('branch'); expect(offered).not.toContain('autoDeploy'); - expect(offered).toHaveLength(10); + expect(offered).toHaveLength(9); }); it('asks nothing more and changes nothing when no setting is ticked', async () => { @@ -102,21 +100,18 @@ describe('promptForEnvironmentUpdate', () => { it('asks only the ticked settings, each offering its current value, and keeps only what changed', async () => { const { services, asked } = servicesAnswering({ - [SETTINGS_QUESTION]: ['cachePriming', 'name', 'buildCmd', 'description'], + [SETTINGS_QUESTION]: ['cachePriming', 'name', 'buildCmd'], Name: 'production', - Description: ' pre-release ', 'Build command': 'npm run build:prod', 'Cache priming': 'enable', }); await expect(promptForEnvironmentUpdate(services, githubContext())).resolves.toEqual({ - description: 'pre-release', buildCmd: 'npm run build:prod', cachePriming: 'enable', }); expect(asked.slice(1).map((question) => [question.message, question.default])).toEqual([ ['Name', 'production'], - ['Description', 'the live site'], ['Build command', 'npm run build'], ['Cache priming', 'disable'], ]); @@ -190,7 +185,7 @@ describe('promptForEnvironmentUpdate', () => { }); it('leaves out a blank answer to an optional text setting', async () => { - const { services } = servicesAnswering({ [SETTINGS_QUESTION]: ['description', 'buildCmd'], Description: ' ' }); + const { services } = servicesAnswering({ [SETTINGS_QUESTION]: ['buildCmd'], 'Build command': ' ' }); await expect(promptForEnvironmentUpdate(services, githubContext())).resolves.toEqual({}); }); @@ -233,14 +228,4 @@ describe('promptForEnvironmentUpdate', () => { ).resolves.toEqual({ passwordProtection: 'disable' }); expect(asked[1].default).toBeUndefined(); }); - - it('refuses a description over 255 characters at the prompt, so it is asked again rather than sent', async () => { - const { services, asked } = servicesAnswering({ [SETTINGS_QUESTION]: ['description'], Description: 'short' }); - - await promptForEnvironmentUpdate(services, githubContext()); - - const validate = asked[1].validate as (value: string) => true | string; - expect(validate('d'.repeat(255))).toBe(true); - expect(validate('d'.repeat(256))).toBe('Description must be 255 characters or fewer; that value is 256 characters.'); - }); }); diff --git a/src/environments/environment.update.prompt.ts b/src/environments/environment.update.prompt.ts index 56aabaf2..991ec815 100644 --- a/src/environments/environment.update.prompt.ts +++ b/src/environments/environment.update.prompt.ts @@ -4,7 +4,6 @@ import { askBranch } from '../git/git.prompt'; import { frameworkLabelOf } from './environment.builder'; import type { ToggleValue } from './environment.inputs'; import { - ENVIRONMENT_DESCRIPTION_MAX_LENGTH, ENVIRONMENT_NAME_MAX_LENGTH, RESPONSE_MODES, TOGGLE_VALUES, @@ -22,7 +21,6 @@ export type EnvironmentChanges = Partial< Pick< EnvironmentUpdateRequest, | 'name' - | 'description' | 'branch' | 'framework' | 'buildCmd' @@ -47,7 +45,6 @@ export interface UpdatePromptContext { const SETTINGS: { setting: Setting; label: string; repositoryOnly?: boolean }[] = [ { setting: 'name', label: 'Name' }, - { setting: 'description', label: 'Description' }, { setting: 'branch', label: 'Branch', repositoryOnly: true }, { setting: 'framework', label: 'Framework preset' }, { setting: 'buildCmd', label: 'Build command' }, @@ -109,11 +106,6 @@ class SettingAsker { switch (setting) { case 'name': return this.text(askText(ux, 'Name', current.name, ENVIRONMENT_NAME_MAX_LENGTH), current.name); - case 'description': - return this.text( - askOptionalText(ux, 'Description', current.description, ENVIRONMENT_DESCRIPTION_MAX_LENGTH), - current.description, - ); case 'branch': return this.text( askBranch(this.services, gitScopeOf(this.context.org, this.context.repository), current.gitBranch), diff --git a/src/environments/environment.update.test.ts b/src/environments/environment.update.test.ts index 435eb8e7..7b42300d 100644 --- a/src/environments/environment.update.test.ts +++ b/src/environments/environment.update.test.ts @@ -105,7 +105,6 @@ describe('EnvironmentUpdater', () => { updater.update( request({ name: 'renamed', - description: 'the live site', branch: 'release', framework: 'NEXTJS', buildCmd: 'npm run build', @@ -124,7 +123,6 @@ describe('EnvironmentUpdater', () => { ...SCOPE, update: { name: 'renamed', - description: 'the live site', gitBranch: 'release', frameworkPreset: 'NEXTJS', buildCommand: 'npm run build', @@ -149,7 +147,7 @@ describe('EnvironmentUpdater', () => { expect(failure).toBeInstanceOf(UsageError); expect((failure as Error).message).toBe( - 'Pass at least one of --name, --description, --branch, --framework, --build-cmd, --server-cmd, ' + + 'Pass at least one of --name, --branch, --framework, --build-cmd, --server-cmd, ' + '--output-dir, --res-mode, --auto-deploy, --cs-auth, --cache-priming, --password-protection; ' + 'none was supplied.', ); diff --git a/src/environments/environment.update.ts b/src/environments/environment.update.ts index 6234d3b7..f225c346 100644 --- a/src/environments/environment.update.ts +++ b/src/environments/environment.update.ts @@ -22,7 +22,6 @@ export interface EnvironmentUpdateRequest { project: string; environment: string; name?: string; - description?: string; branch?: string; framework?: FrameworkPreset; buildCmd?: string; @@ -61,7 +60,6 @@ function pipedPassword(text: string): string { const UPDATABLE_FLAGS: [keyof EnvironmentUpdateRequest, string][] = [ ['name', 'name'], - ['description', 'description'], ['branch', 'branch'], ['framework', 'framework'], ['buildCmd', 'build-cmd'], @@ -96,7 +94,6 @@ function bodyOf( ): EnvironmentUpdate { const fields: EnvironmentUpdate = { name: request.name, - description: request.description, gitBranch: request.branch, frameworkPreset: request.framework, buildCommand: request.buildCmd, diff --git a/src/environments/types.ts b/src/environments/types.ts index c725e78f..fb432f5f 100644 --- a/src/environments/types.ts +++ b/src/environments/types.ts @@ -38,7 +38,6 @@ export interface EnvironmentVariable { export interface Environment { uid?: string; name?: string; - description?: string; gitBranch?: string; frameworkPreset?: string; buildCommand?: string; @@ -64,7 +63,6 @@ export interface PasswordProtectionUpdate { export interface EnvironmentUpdate { name?: string; - description?: string; gitBranch?: string; frameworkPreset?: string; buildCommand?: string; @@ -87,7 +85,6 @@ export interface EnvironmentsPage { export interface CreateEnvironmentInput { name: string; - description?: string; gitBranch?: string; uploadUid?: string; buildCommand?: string; From cac22e9fff0cac4f080fad2f010e253dbc9f5073 Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 11:04:45 +0530 Subject: [PATCH 2/4] CL-8827 | Drop --description from the env:create and env:update README entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated command reference still listed the removed flag. Hand-edit only the two env entries; project --description is unaffected. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c953341..21cd2376 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,7 @@ Create an environment in a Launch project and follow its first deployment ``` USAGE $ csdx launch:env:create [--config ] [-d ] [--org ] [--project ] [--name ] - [--description ] [--branch ] [--framework ] [--build-cmd ] [--server-cmd ] + [--branch ] [--framework ] [--build-cmd ] [--server-cmd ] [--output-dir ] [--res-mode ] [--auto-deploy ] [--cs-auth ] [--var ...] [--dotenv ...] [--from-stack] [-a ] @@ -330,7 +330,6 @@ FLAGS --build-cmd= Build command --config= Path to the local '.cs-launch.json' file --cs-auth= Contentstack Authentication (enable | disable) - --description= Environment description (255 characters or fewer) --dotenv=... Path to a dotenv file, repeatable. Use - to read dotenv content from standard input --framework= Framework preset (Gatsby | NextJs | CRA | CSR | Analog | Angular | Nuxt | Astro | VueJs | Remix | Other) @@ -440,7 +439,7 @@ Update an environment of a Launch project ``` USAGE $ csdx launch:env:update [--config ] [-d ] [--org ] [--project ] [--env ] [--name - ] [--description ] [--branch ] [--framework ] [--build-cmd ] [--server-cmd + ] [--branch ] [--framework ] [--build-cmd ] [--server-cmd ] [--output-dir ] [--res-mode ] [--auto-deploy ] [--cs-auth ] [--cache-priming ] [--password-protection ] [-u ] [-p] [--yes] @@ -455,7 +454,6 @@ FLAGS --cache-priming= Cache priming (enable | disable) --config= Path to the local '.cs-launch.json' file --cs-auth= Contentstack Authentication (enable | disable) - --description= Environment description (255 characters or fewer) --env= Environment name or UID --framework= Framework preset (Gatsby | NextJs | CRA | CSR | Analog | Angular | Nuxt | Astro | VueJs | Remix | Other) From e9b8ce38cda76edfe0cf42678b2c01f2de6857c9 Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 13:02:13 +0530 Subject: [PATCH 3/4] CL-8827 | Word oclif parse errors as one sentence pointing at --help MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit oclif appends "\nSee more help with --help" to every parse error, so an unknown flag printed as two unpunctuated fragments: error: Nonexistent flag: --description See more help with --help reportFailure now replaces that trailing hint with a sentence on the same line: error: Nonexistent flag: --description. Run the command with --help to see its flags. Exit codes are unchanged, and oclif errors without the hint are printed as before. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/core/failure.test.ts | 11 ++++++++++- src/core/failure.ts | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/core/failure.test.ts b/src/core/failure.test.ts index 359abea1..6694986a 100644 --- a/src/core/failure.test.ts +++ b/src/core/failure.test.ts @@ -1,4 +1,4 @@ -import { Errors } from '@oclif/core'; +import { Errors, Parser } from '@oclif/core'; import { handleStandaloneFailure, reportFailure } from './failure'; @@ -37,6 +37,15 @@ describe('reportFailure', () => { expect(lines).toEqual(['\u001b[31merror: Nonexistent flag: --json\u001b[39m']); }); + it('words an oclif parse error as one sentence pointing at --help, keeping its exit code', async () => { + const refusal = (await Parser.parse(['--description', 'x'], { flags: {} }).catch((error: unknown) => error)) as Error; + const { lines, outcome } = report(refusal); + const thrown = await outcome; + + expect(lines).toEqual(['error: Nonexistent flag: --description. Run the command with --help to see its flags.']); + expect(thrown.oclif.exit).toBe(2); + }); + it('prints an unexpected failure the same way and exits 1', async () => { const { lines, fallback, outcome } = report(new Error('boom')); const thrown = await outcome; diff --git a/src/core/failure.ts b/src/core/failure.ts index 0e638beb..c50df11c 100644 --- a/src/core/failure.ts +++ b/src/core/failure.ts @@ -2,6 +2,7 @@ import { Errors, settings } from '@oclif/core'; import { EXIT_RUNTIME } from './constants'; import { styled } from './style'; +import { asSentence } from './values'; export interface FailureOutput { print: (line: string) => void; @@ -36,6 +37,18 @@ export function failureOutputOf(fallback: (err: Error) => Promise): Fai }; } +const OCLIF_HELP_HINT = '\nSee more help with --help'; + +const HELP_SENTENCE = 'Run the command with --help to see its flags.'; + +function asOneSentence(message: string): string { + if (!message.endsWith(OCLIF_HELP_HINT)) { + return message; + } + + return `${asSentence(message.slice(0, -OCLIF_HELP_HINT.length))} ${HELP_SENTENCE}`; +} + function alreadyReported(err: Error): boolean { return (err as Error & { skipOclifErrorHandling?: boolean }).skipOclifErrorHandling === true; } @@ -56,7 +69,7 @@ export async function reportFailure(err: Error, output: FailureOutput): Promise< } if (isOclifError(err)) { - return failWith(err.message, err.oclif.exit, output); + return failWith(asOneSentence(err.message), err.oclif.exit, output); } if (output.debug) { From a848aee146a215ec6e3a28627312359bf8082a64 Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 15:00:32 +0530 Subject: [PATCH 4/4] CL-8827 | Put the --help hint for parse errors on its own line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keep oclif's error as the first sentence and move the hint to a second line: error: Nonexistent flag: --description. Run the command with --help to see its flags. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/core/failure.test.ts | 4 ++-- src/core/failure.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/failure.test.ts b/src/core/failure.test.ts index 6694986a..eee600eb 100644 --- a/src/core/failure.test.ts +++ b/src/core/failure.test.ts @@ -37,12 +37,12 @@ describe('reportFailure', () => { expect(lines).toEqual(['\u001b[31merror: Nonexistent flag: --json\u001b[39m']); }); - it('words an oclif parse error as one sentence pointing at --help, keeping its exit code', async () => { + it('words an oclif parse error as a sentence with the --help hint on its own line, keeping its exit code', async () => { const refusal = (await Parser.parse(['--description', 'x'], { flags: {} }).catch((error: unknown) => error)) as Error; const { lines, outcome } = report(refusal); const thrown = await outcome; - expect(lines).toEqual(['error: Nonexistent flag: --description. Run the command with --help to see its flags.']); + expect(lines).toEqual(['error: Nonexistent flag: --description.\nRun the command with --help to see its flags.']); expect(thrown.oclif.exit).toBe(2); }); diff --git a/src/core/failure.ts b/src/core/failure.ts index c50df11c..90bf69b1 100644 --- a/src/core/failure.ts +++ b/src/core/failure.ts @@ -41,12 +41,12 @@ const OCLIF_HELP_HINT = '\nSee more help with --help'; const HELP_SENTENCE = 'Run the command with --help to see its flags.'; -function asOneSentence(message: string): string { +function withHelpSentence(message: string): string { if (!message.endsWith(OCLIF_HELP_HINT)) { return message; } - return `${asSentence(message.slice(0, -OCLIF_HELP_HINT.length))} ${HELP_SENTENCE}`; + return `${asSentence(message.slice(0, -OCLIF_HELP_HINT.length))}\n${HELP_SENTENCE}`; } function alreadyReported(err: Error): boolean { @@ -69,7 +69,7 @@ export async function reportFailure(err: Error, output: FailureOutput): Promise< } if (isOclifError(err)) { - return failWith(asOneSentence(err.message), err.oclif.exit, output); + return failWith(withHelpSentence(err.message), err.oclif.exit, output); } if (output.debug) {