Quick Start
This guide creates a pok CLI, defines one command, and runs it with both explicit flags and interactive prompts.
Create a new project
pnpm create pokit my-cliOr add pok to an existing project
pnpm add @pokit/coreDefine a command
commands/deploy.ts
import { z } from "zod";
import { defineCommand } from "@pokit/core";
export const command = defineCommand({
label: "Deploy to environment",
context: {
env: {
from: "flag",
schema: z.enum(["staging", "prod"]),
description: "Target environment",
},
},
run: async (r, ctx) => {
await r.group("Deploy", { layout: "sequence" }, async (g) => {
await g.activity("Build", () => r.exec("npm run build"));
await g.activity("Push", () => r.exec(`deploy --env ${ctx.context.env}`));
});
},
});Run with a flag
$ mycli deploy --env stagingRun with interactive prompt
$ mycli deploy
? Select environment > staging / prod