Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#795 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
77/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃

调研方向

从 src/cli.ts 开始,追踪 argv 预扫描如何设置 wantsHelp 并控制扩展分发;将其与 examples/extensions/basic/index.js 中捆绑的示例进行比较。使用 elastic demo --help 运行复现,并确认扩展收到其参数并打印自己的用法说明。

由索引模型根据 Issue 内容生成。

描述

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)

主要语言
TypeScript
星标
51
派生
27
平均合并
1 天 19 分钟
30 天内合并 PR
50

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

elastic/cli 的其他 Issue

查看 elastic/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。