cli: export the terminal display-width measure
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #8982 by @Yi-111-a — merged
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- devtools
Research direction
Start in the CLI module's CliOutput.ts and locate the internal visualLength measure (introduced by #7572 for help alignment); it already strips ANSI styling and applies grapheme/East Asian Width rules. Export it as CliOutput.displayWidth with a doc comment, verify the module's public surface (re-export path for effect/cli) exposes it, and add tests asserting the examples in the issue (file name width 8, accented char 1, emoji 2). Done when CliOutput.displayWidth("ファイル") === 8 and styled text measures the same as unstyled.
Written by the indexing model from the issue text.
Description
What is the problem this feature would solve?
#7572 fixed help alignment by measuring text in terminal cells instead of UTF-16 code units, which closed #7557. The measure itself stayed internal (visualLength in CliOutput.ts), so the second half of that issue is still open.
Anything a CLI draws next to the built-in output has to measure text by the same rules to line up with it: a custom CliOutput.Formatter, a boxed banner, a table, a prompt built on Prompt.Custom. Today the only options are copying the grapheme and East Asian Width logic into the application, or adding string-width. Either way the application's measure can disagree with the one the built-in help uses, so the two drift as either side changes.
What is the feature you are proposing to solve the problem?
Export the existing measure, for example as CliOutput.displayWidth:
CliOutput.displayWidth("ファイル") // 8
CliOutput.displayWidth("é") // 1
CliOutput.displayWidth("1️⃣") // 2
It should strip ANSI styling as it does today, so styled and unstyled text measure the same. No new logic is needed, only the export and a doc comment.
What alternatives have you considered?
- Reimplementing it per application: what we do today. It duplicates Unicode knowledge that already lives in Effect, and the two implementations can disagree.
string-width: an extra dependency that measures by its own tables, so it can still disagree with the built-in help.- A home in
effect/Stringinstead ofeffect/cli: also fine, since the measure is useful outside the CLI module.
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 808
- Avg merge
- 10h 38m
- Merged PRs (30d)
- 495
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Effect-TS/effect
-
BrowserWorkerRunner: port finalizer throws when the worker global has no close() (Bun)Possibly taken @santiago-ramos-02 claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Effect-TS/effect#8635 · 3 comments ·
Maintainers usually reply within 1 day
-
Support {self: this} for fnUntracedMay be free again @ArjunCodess claimed this 22 days ago, and no pull request is open. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Effect-TS/effect#8101 · 1 comment ·
Maintainers usually reply within 1 day
-
Schema.isPowerOfPossibly taken @effect-bot claimed this today. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
add Effect-native McpClientPossibly taken @lloydrichards claimed this 5 days ago. Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 8/100
Effect-TS/effect#8912 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 48/100
Maintainers usually reply within 1 day
All issues in Effect-TS/effect
Similar issues
-
area/frontend area/v2 kind/bug priority/needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
kubeflow/notebooks#1498 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
P1
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
SuruchBoss/Cwork#90 ·
-
bug cli service
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
521xueweihan/HelloGitHub#3922 ·