@bunli/plugin-completions
v0.3.5
Published
Shell completions plugin for Bunli CLI framework
Maintainers
Readme
@bunli/plugin-completions
Tab-powered shell completions for Bunli CLIs.
This plugin delegates script generation and the dynamic completion protocol (complete -- <args>) to @bomb.sh/tab, and builds Tab’s command tree from Bunli’s generated metadata (.bunli/commands.gen.ts).
Install
bun add @bunli/plugin-completionsSetup
import { defineConfig } from '@bunli/core'
import { completionsPlugin } from '@bunli/plugin-completions'
export default defineConfig({
name: 'my-cli',
plugins: [
completionsPlugin({
// generatedPath: '.bunli/commands.gen.ts',
// commandName: 'my-cli',
// executable: 'my-cli',
// includeAliases: true,
// includeGlobalFlags: true
})
]
})You must have .bunli/commands.gen.ts available (run bunli generate, or enable codegen in your build).
Commands
Generate a completion script
my-cli completions zsh
my-cli completions bash
my-cli completions fish
my-cli completions powershellDynamic completion protocol callback (used by the shell scripts)
my-cli complete -- <args...>Do not build your own integrations on Bunli’s parsed positional args for this path: Tab relies on a trailing empty-string sentinel ('') to detect “ends with space”, and Bunli’s parser drops empty strings. The implementation uses runtime.args directly.
Shell Setup Examples
Bash
source <(my-cli completions bash)Zsh
source <(my-cli completions zsh)Fish
my-cli completions fish > ~/.config/fish/completions/my-cli.fishPowerShell
my-cli completions powershell | Out-String | Invoke-ExpressionNotes
Runtime packaging
@bunli/plugin-completions publishes a bundled runtime (dist/index.js) that already includes Tab. Downstream consumers only install @bunli/plugin-completions and do not need a separate runtime dependency on @bomb.sh/tab.
@bomb.sh/tab types note
As of @bomb.sh/[email protected], the published package references dist/t.d.ts but ships only dist/t-<hash>.d.ts. Bunli’s monorepo uses bun patch during development/CI to keep TypeScript builds unblocked until upstream fixes packaging.
