Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

cli: help examples are fixed at construction and can't reflect where a command is mounted

Đã đóng
#6,745 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
cli

Hướng nghiên cứu

Start at Command.withExamples and buildHelpDoc, which already receives commandPath for the USAGE line. Trace how examples are stored and rendered, then verify that the new callback form resolves against the mounted path while the existing array form remains unchanged. Confirm the generated help examples work for commands mounted directly and as subcommands.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
What is the problem this feature would solve?

USAGE reflects where a command is mounted; its examples don't — they're fixed strings written at construction. Mount one command in two places (own bin, and subcommand of a larger CLI) and its examples describe an invocation that doesn't work.

It can't be fixed in user land: a child is built before withSubcommands attaches it, so the path isn't knowable when withExamples runs. The only workaround is threading the mount path into every command factory by hand.

What is the feature you are proposing to solve the problem?

An overload of Command.withExamples taking (commandPath: ReadonlyArray<string>) => ReadonlyArray<Example>, resolved in buildHelpDoc, which already receives commandPath for the USAGE line. Additive — the array form is unchanged.

Command.withExamples(create, (path) => [
  { command: `${path.join(" ")} --yes`, description: "Take every default." },
])
What alternatives have you considered?
  • Threading the mount path in by hand — what we do now: every command factory takes the path it's mounted at and interpolates it into its own examples. Works, but re-supplies what the parser already computes, and nothing checks the two agree.
  • Prefixing examples at the mount site via the public examples field and withExamples. Same information written in the same place, and it doesn't recurse into grandchildren.
  • Auto-prefixing relative examples with the usage path. Nicest to write, but breaks every existing absolute example — would need its own combinator.
  • A custom help renderer that rewrites examples against the path. Not available: run takes only { version }.
Ngôn ngữ chính
TypeScript
Star
16.7k
Fork
808
Merge trung bình
11 giờ 11 phút
Pull request đã merge (30 ngày)
840

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Effect-TS/effect

Tất cả issue của Effect-TS/effect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.