Overview
Official Crust plugins.
The plugins package provides official plugins for common CLI features. It depends on @crustjs/core.
Install
bun add @crustjs/pluginsExports
Plugin Factories
| Export | Description |
|---|---|
helpPlugin() | Adds --help / -h and auto-generates help text |
versionPlugin() | Adds --version / -v to display version |
autoCompletePlugin() | Suggests corrections for mistyped subcommands |
updateNotifierPlugin() | Checks npm for newer versions and displays update notice |
Utilities
| Export | Description |
|---|---|
renderHelp(command, path?) | Generate help text programmatically |
Types
| Type | Description |
|---|---|
VersionValue | string | (() => string) — version plugin input |
AutoCompletePluginOptions | Options for the autocomplete plugin |
UpdateNotifierPluginOptions | Options for the update notifier plugin |
UpdateNotifierCacheConfig | Cache configuration for update notifier |
UpdateNotifierCacheAdapter | Cache adapter interface for update notifier |
UpdateNotifierPackageManager | Package manager union for update notifier |
UpdateNotifierInstallScope | Install scope union for update notifier |
Usage
import {
helpPlugin,
versionPlugin,
autoCompletePlugin,
updateNotifierPlugin,
} from "@crustjs/plugins";
import { Crust } from "@crustjs/core";
const main = new Crust("my-cli")
.meta({ description: "My CLI" })
.use(versionPlugin("1.0.0"))
.use(autoCompletePlugin({ mode: "help" }))
.use(helpPlugin())
.use(updateNotifierPlugin({ packageName: "my-cli", currentVersion: "1.0.0" }))
.run(() => {
console.log("Hello!");
});
await main.execute();When to Use Directly
Use @crustjs/plugins directly when you're already importing from @crustjs/core and want to add official plugins without the crust CLI binary.
For most CLI applications, install both @crustjs/core and @crustjs/plugins as runtime dependencies.