Version
Add a root-only version flag.
Usage
import { Crust } from "@crustjs/core";
import { version } from "@crustjs/extensions";
const app = new Crust("my-cli", { version: "1.2.3" }).extend(version()).action(() => {});
await app.execute();
$ my-cli --version
my-cli v1.2.3version() owns the root-only --version and -v flag. It writes through the invocation's stdout callback and handles the invocation before the Command Action.
API
version();
version("1.2.3");
version(() => process.env.APP_VERSION ?? "dev");Without an explicit value, version() requires root version metadata. A value typed string | undefined still requires that metadata, as described by RootMetaKey. An explicit value affects only the version flag and does not populate root metadata for completion, skills, or other Extensions.
version("1.2.3", { format: "plain" });
// $ my-cli --version
// 1.2.3Prop
Type
A format function returns the line written for the flag. An explicit value may be a string or a function that resolves a string when the flag is handled.