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

Extension --help prints root help instead of running the extension

Đang mở Phù hợp với người mới
#795 0 bình luận 0 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
cli, developer-experience

Hướng nghiên cứu

Bắt đầu từ src/cli.ts và theo dõi cách bước quét trước argv đặt wantsHelp và điều khiển việc dispatch extension; so sánh với ví dụ đi kèm trong examples/extensions/basic/index.js. Chạy bản tái hiện bằng elastic demo --help và xác nhận extension nhận các đối số của nó và in hướng dẫn sử dụng riêng.

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

Mô tả

tracking

Summary

When --help or -h appears anywhere in the arguments, the CLI does not dispatch to an installed extension; it prints the root elastic --help instead. Extensions cannot show their own help, and an extension cannot receive -h/--help as an argument at all.

This contradicts the bundled example, whose header says elastic demo --help # shows usage (examples/extensions/basic/index.js), and that extension does handle --help itself.

Reproduction

  1. elastic extension create demo --path ./examples/extensions/basic
  2. elastic demo --help

Expected: the extension runs and prints Usage: elastic demo [--help].

Actual: root elastic --help output.

Seen with @elastic/cli 0.7.0 and a Rust extension (elastic console --help). Same code on main.

Notes

The argv pre-scan sets wantsHelp for any --help/-h, and extension dispatch is gated on it (src/cli.ts):

if (arg === '--help' || arg === '-h') wantsHelp = true
// ...
if (!wantsHelp && firstArg != null && !program.commands.some(c => c.name() === firstArg)) {
  // findExtension / runExtension
}

A guess at a fix: when firstArg is an installed extension, dispatch regardless of wantsHelp, since everything after the extension name belongs to the extension (process.argv.slice(3) is already passed through).

Related

  • #738 (extensions ignore --use-context / --config-file), another case of argv handling around extension dispatch.

authored by Pi Coding Agent (Claude Opus 4)

Ngôn ngữ chính
TypeScript
Star
51
Fork
27
Merge trung bình
1 ngày 19 phút
Pull request đã merge (30 ngày)
50

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

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 elastic/cli

Tất cả issue của elastic/cli

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.