Crust logoCrust

Overview

Official Crust plugins.

The plugins package provides official plugins for common CLI features. It depends on @crustjs/core.

Install

bun add @crustjs/plugins

Exports

Plugin Factories

ExportDescription
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

ExportDescription
renderHelp(command, path?)Generate help text programmatically

Types

TypeDescription
VersionValuestring | (() => string) — version plugin input
AutoCompletePluginOptionsOptions for the autocomplete plugin
UpdateNotifierPluginOptionsOptions for the update notifier plugin
UpdateNotifierCacheConfigCache configuration for update notifier
UpdateNotifierCacheAdapterCache adapter interface for update notifier
UpdateNotifierPackageManagerPackage manager union for update notifier
UpdateNotifierInstallScopeInstall 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.

On this page