Extensions
Official application-wide capabilities for Crust CLIs.
@crustjs/extensions exports six official Extensions and three completion renderers.
Install
npm install @crustjs/extensionsUsage
import { Crust } from "@crustjs/core";
import {
completion,
didYouMean,
help,
noColor,
updateNotifier,
version,
} from "@crustjs/extensions";
export const app = new Crust("my-cli", { version: "0.2.0" }).extend(
noColor(),
version(),
help(),
completion(),
didYouMean(),
updateNotifier({ packageName: "my-cli" }),
);
Register Extensions on the root builder. Contributions follow .extend() registration order, and their types and naming constraints are part of the Extension contract.
Exports
| Export | Contribution |
|---|---|
help() | Recursive --help / -h flag and help rendering |
renderHelp(command, path?) | Render help text from a Command Snapshot |
version(value?, options?) | Root-only --version / -v flag |
completion(options?) | Shell completion command and build artifacts |
renderBashCompletion(root, options?) | Render bash completion from a Command Snapshot |
renderZshCompletion(root, options?) | Render zsh completion from a Command Snapshot |
renderFishCompletion(root, options?) | Render fish completion from a Command Snapshot |
didYouMean(options?) | COMMAND_NOT_FOUND presentation |
noColor() | Recursive --color / --no-color flag |
updateNotifier(options) | Post-action npm update notice |