Skip to content

fix(cli): replace all hyphens in shell completion command names#6213

Merged
IMax153 merged 2 commits into
Effect-TS:mainfrom
lihan3238:fix/cli-completions-hyphen-replace
May 11, 2026
Merged

fix(cli): replace all hyphens in shell completion command names#6213
IMax153 merged 2 commits into
Effect-TS:mainfrom
lihan3238:fix/cli-completions-hyphen-replace

Conversation

@lihan3238
Copy link
Copy Markdown
Contributor

Summary

  • Fix command.replace("-", "__") to use command.replaceAll("-", "__") in both bash and zsh completion generators
  • The previous code only replaced the first hyphen in command names, causing multi-hyphenated commands (e.g., type-check-v2) to produce incorrect sanitized names like type__check-v2 instead of type__check__v2

Background

The shell completion generators sanitize command names by replacing hyphens with double underscores (since hyphens are not allowed in bash/zsh function identifiers). However, String.prototype.replace() with a string argument only replaces the first occurrence, so commands with more than one hyphen were only partially sanitized.

Partially addresses #6114

Test plan

  • Verified that both bash and zsh completion generators use the same fix
  • Existing completion snapshot tests should be updated to reflect the fix

The shell completion generators for bash and zsh used
`command.replace("-", "__")` which only replaces the first hyphen
in command names. For commands with multiple hyphens like
`type-check-v2`, this produced `type__check-v2` instead of the
correct `type__check__v2`.

Partially addresses Effect-TS#6114
@lihan3238 lihan3238 requested a review from IMax153 as a code owner May 5, 2026 15:40
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog May 5, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: 345ce6d

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

This PR includes changesets to release 1 package
Name Type
@effect/cli 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

@IMax153 IMax153 merged commit 1a63ec8 into Effect-TS:main May 11, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog May 11, 2026
@github-actions github-actions Bot mentioned this pull request May 11, 2026
Hoishin added a commit to Hoishin/effect that referenced this pull request May 18, 2026
* upstream/main: (126 commits)
  fix(@effect/cli): use Ansi.blackBright for Weak spans so --help is readable on dark terminals (Effect-TS#6208)
  fix(cli): replace all hyphens in shell completion command names (Effect-TS#6213)
  Version Packages (Effect-TS#6218)
  Support null K8s lastTransitionTime values (Effect-TS#6217)
  Version Packages (Effect-TS#6197)
  Backport workflow suspension failure fixes (Effect-TS#6196)
  clone full v4 history
  Version Packages (Effect-TS#6195)
  preserve fiber context in HttpLayerRouter.addHttpApi so API-level middleware is applied (Effect-TS#6147)
  correct typos in source code (receive, separate) (Effect-TS#6110)
  docs(@effect/vitest): fix return type in fails example (Effect-TS#6163)
  make RpcSerialization.msgPack options configurable (Effect-TS#6161)
  update msgpackr to 1.11.10 for Cloudflare Workers compatibility (Effect-TS#6191)
  fix: floor TestClock nanoseconds before BigInt conversion (Effect-TS#6194)
  chore: disable TypeScript's nightly workflow (Effect-TS#6193)
  Version Packages (Effect-TS#6189)
  (fix: ai-openai) Remove strict param from the OpenAI request body (Effect-TS#6188)
  Version Packages (Effect-TS#6142)
  fix(ai-openai): deduplicate response.output items to prevent invalid JSON concatenation (Effect-TS#6178)
  Change 'in-memory' to 'in_memory' in prompt cache enums (Effect-TS#6187)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants