Multi-command
Register subcommands with Commander while reusing the same oscli runtime.
Use subcommands when one executable needs multiple entry points. oscli keeps
Commander in charge of parsing and routing, while prompts, flags, output, and
themes stay consistent across commands.
Example
import { createCLI } from "@oscli-dev/oscli";
export const cli = createCLI((b) => ({
description: "workspace tool",
prompts: {
name: b.text().label("Name").default("my-app"),
},
}));
cli.command("init", async () => {
await cli.prompt.name();
cli.success(`Initialized ${cli.storage.name}`);
});
cli.command("deploy", async () => {
cli.log("info", "Deploying...");
});
await cli.run();Behavior
Prop
Type
Help and suggestions
If no subcommand is provided, Commander prints generated help output. If the
user enters an unknown subcommand, oscli formats the error and uses the
suggestion helper when a close match exists.
oscli depoyThat prints an error like this:
Unknown command: "depoy"
→ Did you mean: deploy?cli.command() does not create command-specific prompt definitions. The same
prompt and flag builders are shared across commands, and storage is cleared
before each command handler runs.