Skip to content

Add CLI output presenter - #6743

Open
IMax153 wants to merge 1 commit into
mainfrom
issue-6313-cli-output-policy
Open

Add CLI output presenter#6743
IMax153 wants to merge 1 commit into
mainfrom
issue-6313-cli-output-policy

Conversation

@IMax153

@IMax153 IMax153 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • add a scoped CliOutput.Presenter service with structured help, invalid-invocation, and version events
  • route built-in help and version output plus Command.runWith help failures through the presenter
  • preserve existing console behavior by default while allowing output to be suppressed, redirected, or replaced
  • add focused coverage for explicit help, implicit help, version output, invalid invocations, and silent custom presentation

Testing

  • pnpm lint-fix
  • pnpm lint
  • pnpm docgen from packages/effect
  • pnpm --filter effect test --run test/unstable/cli/Command.test.ts
  • pnpm --filter effect check

Root pnpm check remains blocked by unrelated stale or missing generated outputs in platform packages.

Closes #6313

Summary by CodeRabbit

  • New Features
    • Added customizable presentation for CLI help, version information, and invalid invocation messages.
    • CLI output can now be suppressed, redirected, or replaced through a configurable presenter.
    • Added structured events for requested or implicit help, version output, and invocation errors.
  • Bug Fixes
    • Centralized CLI output handling to ensure consistent presentation across commands and built-in flags.
  • Tests
    • Added coverage confirming custom presenters receive expected events without direct terminal output.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c1ef5a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-slopcop effect-slopcop Bot added 4.0 enhancement New feature or request labels Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ab9506f9-690c-46fb-ae8e-c523d97aeb7a

📥 Commits

Reviewing files that changed from the base of the PR and between cccd029 and c1ef5a4.

📒 Files selected for processing (5)
  • .changeset/add-cli-output-presenter.md
  • packages/effect/src/unstable/cli/CliOutput.ts
  • packages/effect/src/unstable/cli/Command.ts
  • packages/effect/src/unstable/cli/GlobalFlag.ts
  • packages/effect/test/unstable/cli/Command.test.ts

📝 Walkthrough

Walkthrough

CLI output handling now uses a scoped CliOutput.Presenter service for help, invalid invocations, and version events. The default presenter preserves formatter and console behavior, while custom presenters can replace it. Tests verify event delegation and suppressed direct console output.

Changes

CLI output presentation

Layer / File(s) Summary
Presenter contract and default implementation
packages/effect/src/unstable/cli/CliOutput.ts
Defines structured help, invalid-invocation, and version events, provides a default formatter-backed presenter, and adds custom presenter layer support.
CLI presentation integration
packages/effect/src/unstable/cli/Command.ts, packages/effect/src/unstable/cli/GlobalFlag.ts
Routes implicit help, invalid invocation, explicit help, and version output through CliOutput.Presenter.
Presentation validation and release metadata
packages/effect/test/unstable/cli/Command.test.ts, .changeset/add-cli-output-presenter.md
Tests captured presenter events and confirms no direct terminal output; adds patch release metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Command
  participant GlobalFlag
  participant Presenter as CliOutput.Presenter
  participant Formatter
  participant Console
  CLI->>Command: invoke command
  Command->>Presenter: present Help or InvalidInvocation
  CLI->>GlobalFlag: process --help or --version
  GlobalFlag->>Presenter: present Help or Version
  Presenter->>Formatter: format event output
  Formatter-->>Presenter: formatted text
  Presenter->>Console: write log or error output
Loading

Suggested reviewers: tim-smart, gcanti

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The new presenter service lets Command.runWith and built-in help/version flows suppress, redirect, or replace console output as requested.
Out of Scope Changes check ✅ Passed All changes support the CLI output presentation refactor and its tests; no unrelated code paths were introduced.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

| File Name | Current Size | Previous Size | Difference |
|:----------|:------------:|:-------------:|:----------:|
| 'basic.ts' | 6.63 KB | 6.63 KB | 0.00 KB (0.00%) |
| 'batching.ts' | 9.42 KB | 9.42 KB | 0.00 KB (0.00%) |
| 'brand.ts' | 6.31 KB | 6.31 KB | 0.00 KB (0.00%) |
| 'cache.ts' | 10.12 KB | 10.12 KB | 0.00 KB (0.00%) |
| 'config.ts' | 19.90 KB | 19.90 KB | 0.00 KB (0.00%) |
| 'differ.ts' | 20.03 KB | 20.03 KB | 0.00 KB (0.00%) |
| 'http-client.ts' | 20.94 KB | 20.94 KB | 0.00 KB (0.00%) |
| 'logger.ts' | 10.28 KB | 10.28 KB | 0.00 KB (0.00%) |
| 'metric.ts' | 8.55 KB | 8.55 KB | 0.00 KB (0.00%) |
| 'optic.ts' | 7.33 KB | 7.33 KB | 0.00 KB (0.00%) |
| 'pubsub.ts' | 14.26 KB | 14.26 KB | 0.00 KB (0.00%) |
| 'queue.ts' | 11.09 KB | 11.09 KB | 0.00 KB (0.00%) |
| 'schedule.ts' | 10.27 KB | 10.27 KB | 0.00 KB (0.00%) |
| 'schema-class.ts' | 18.86 KB | 18.86 KB | 0.00 KB (0.00%) |
| 'schema-fromJsonSchemaDocument.ts' | 28.78 KB | 28.78 KB | 0.00 KB (0.00%) |
| 'schema-representation-roundtrip.ts' | 25.09 KB | 25.09 KB | 0.00 KB (0.00%) |
| 'schema-string-transformation.ts' | 12.95 KB | 12.95 KB | 0.00 KB (0.00%) |
| 'schema-string.ts' | 10.65 KB | 10.65 KB | 0.00 KB (0.00%) |
| 'schema-template-literal.ts' | 14.85 KB | 14.85 KB | 0.00 KB (0.00%) |
| 'schema-toArbitraryLazy.ts' | 21.66 KB | 21.66 KB | 0.00 KB (0.00%) |
| 'schema-toCodeDocument.ts' | 24.10 KB | 24.10 KB | 0.00 KB (0.00%) |
| 'schema-toCodecJson.ts' | 19.00 KB | 19.00 KB | 0.00 KB (0.00%) |
| 'schema-toEquivalence.ts' | 18.73 KB | 18.73 KB | 0.00 KB (0.00%) |
| 'schema-toFormatter.ts' | 18.59 KB | 18.59 KB | 0.00 KB (0.00%) |
| 'schema-toJsonSchemaDocument.ts' | 22.23 KB | 22.23 KB | 0.00 KB (0.00%) |
| 'schema-toRepresentation.ts' | 19.27 KB | 19.27 KB | 0.00 KB (0.00%) |
| 'schema.ts' | 18.12 KB | 18.12 KB | 0.00 KB (0.00%) |
| 'stm.ts' | 12.05 KB | 12.05 KB | 0.00 KB (0.00%) |
| 'stream.ts' | 9.37 KB | 9.37 KB | 0.00 KB (0.00%) |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command.runWith has no way to opt out of its own console-rendered help/error output on parse failures

2 participants