@gutenye/commander-completion-carapace

中文文档
1.0.9发布于 2025/07/25MITES Module近 30 天下载 20.8万

Effortlessly add intelligent autocomplete support to your Commander.js CLI app using Carapace. Supports Bash, Zsh, Fish, Nushell and more

原始使用文档
文档目录6 节
  1. 🌟 Features
  2. 🚀 Getting Started
  3. 1️⃣ Install
  4. 2️⃣ Write Completion Code
  5. 3️⃣ Use the Completion
  6. 🤝 Contribute

⌘ Commander Completion Carapace ⌘

Stars NPM Version License PRs Welcome

Effortlessly add intelligent autocomplete support to your Commander.js CLI app using Carapace. It works with a wide range of shells, making your CLI tools more intuitive and user-friendly.

Show your ❤️ and support by starring this project and following the author, Guten Ye!

screenrecording

🌟 Features

  • ⌘ Multiple Shells Support: Works with Bash, Zsh, Fish, Nushell, and more.
  • 🚄 Blazing Fast Completion: Experience instantaneous completion with no delays.
  • 🔗 Carapace Integration: Unlock all the powerful features of Carapace, including advanced shell completions.
  • 🧑‍💻 Effortless Integration: Easily add completion support to your Commander.js based CLI app.

🚀 Getting Started

1️⃣ Install

First, make sure Carapace is installed, as it powers the completion functionality:

bun add @gutenye/commander-completion-carapace commander

2️⃣ Write Completion Code

Now, integrate completion support into your Commander.js application by adding the following code:

import { program, Option } from '@gutenye/commander-completion-carapace'

program
  .name('hello')
  .enableCompletion()

program.command('cmd1 [...files]')
  .description('Description')
  .option('--option1', 'Description')
  .completion({   // pass to carapace 
    positonalany: ['$files'] // dynamic completion
  })
  .action(() => {})

await program.installCompletion() // Creates hello.yaml Carapace spec file

program.parse()

3️⃣ Use the Completion

hello      # Will create the Carapace spec file the first time it runs
hello<Tab> # Press Tab to see completions for commands and options

🤝 Contribute

We welcome contributions! Whether it’s bug reports, feature suggestions, or pull requests, your involvement makes this project better.

How to Contribute:

  1. Fork the Repository
  2. Open a Pull Request on Github

Thank you for using Commander Completion Carapace! ✨ If you found it helpful, please ⭐️ star the project ️️⭐ on GitHub. If you encounter any issues, feel free to report an issue on Github.

Special thanks to all the contributors:

⬆ Back to top ⬆

版本与发布记录

@gutenye/commander-completion-carapace 共发布 10 个版本,首次发布于 2024/12/26;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.9latest2025/07/251.3 年前
1.0.82025/03/191.7 年前
1.0.72024/12/261.9 年前
1.0.62024/12/261.9 年前
1.0.52024/12/261.9 年前
1.0.42024/12/261.9 年前

关于 @gutenye/commander-completion-carapace 的常见问题

@gutenye/commander-completion-carapace 是什么?

Effortlessly add intelligent autocomplete support to your Commander.js CLI app using Carapace. Supports Bash, Zsh, Fish, Nushell and more

如何安装 @gutenye/commander-completion-carapace?

在项目目录运行 npm install @gutenye/commander-completion-carapace,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:commander(^13 || ^12.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gutenye/commander-completion-carapace 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gutenye__commander-completion-carapace 是否存在。

@gutenye/commander-completion-carapace 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gutenye/commander-completion-carapace 可以商用吗?

@gutenye/commander-completion-carapace 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gutenye/commander-completion-carapace 的下载量有多少?

根据 npm 官方下载统计,@gutenye/commander-completion-carapace 在 2026/10/17 – 2026/11/15 这 30 天内被下载 208,450 次,日均约 6,948 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gutenye/commander-completion-carapace 还在维护吗?

最新版本 1.0.9 发布于 2025/07/25(1.3 年前);至今共发布 10 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/12/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。