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
noColorPlugin()Adds --color / --no-color runtime color control
versionPlugin()Adds --version / -v to display version
didYouMeanPlugin()Suggests corrections for mistyped subcommands
updateNotifierPlugin()Checks npm for newer versions and displays update notice
completionPlugin()Generates bash/zsh/fish tab-completion scripts

Utilities

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

Types

TypeDescription
VersionValuestring | (() => string) — version plugin input
DidYouMeanPluginOptionsOptions for the did-you-mean 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
CompletionPluginOptionsOptions for the completion plugin
CompletionShell"bash" | "zsh" | "fish" shell union

Manual pages are provided by @crustjs/man (build-time mdoc), not by this package.

Usage

import {
  helpPlugin,
  noColorPlugin,
  versionPlugin,
  didYouMeanPlugin,
  updateNotifierPlugin,
  completionPlugin,
} from "@crustjs/plugins";
import { Crust } from "@crustjs/core";

const main = new Crust("my-cli")
  .meta({ description: "My CLI" })
  .use(noColorPlugin())
  .use(versionPlugin("1.0.0"))
  .use(didYouMeanPlugin({ mode: "help" }))
  .use(helpPlugin())
  .use(updateNotifierPlugin({ packageName: "my-cli", currentVersion: "1.0.0" }))
  .use(completionPlugin({ version: "1.0.0" }))
  .run(() => {
    console.log("Hello!");
  });

await main.execute();

noColorPlugin() should be registered before plugins that may render output and short-circuit, such as helpPlugin(), so --color and --no-color can affect their output.

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