Crust logoCrust

Did You Mean

Present command-not-found errors with typo suggestions.

Usage

cli.ts
import { Crust, defineCommand } from "@crustjs/core";
import { didYouMean } from "@crustjs/extensions";

const app = new Crust("my-cli")
	.extend(didYouMean())
	.add(defineCommand("deploy", (command) => command.action(() => {})));

await app.execute();
$ my-cli deply
Unknown command "deply". Did you mean "deploy"?

Available commands: deploy
# exit code: 1

didYouMean() handles COMMAND_NOT_FOUND during execute() presentation. Suggestions use visible sibling command names and aliases, then print the canonical name.

Options

new Crust("my-cli").extend(didYouMean({ mode: "help" }));
OptionTypeDefault
mode"error" | "help""error"

"error" writes the message and available commands to stderr. "help" writes the message and parent help to stdout, while core keeps the nonzero exit code.

An action-bearing parent treats an unmatched token as a positional argument, so this Extension only suggests a command when routing produces COMMAND_NOT_FOUND. Programmatic run() returns the failed outcome without running presentation hooks.

On this page