@pokit/prompter-clack
@pokit/prompter-clack provides a Prompter implementation backed by @clack/prompts.
Installation
bun add @pokit/prompter-clackConfiguration
import { run } from '@pokit/core';
import { createPrompter } from '@pokit/prompter-clack';
await run(args, {
prompter: createPrompter(),
// ...
});Prompt rendering
The adapter renders interactive select, multiselect, confirm, and text prompts:
◆ mycli
│
◇ What would you like to do?
│ ● build - Build the project
│ ○ deploy - Deploy to environment
│ ○ test - Run tests
│
◇ Select environment
│ ● staging
│ ○ production
│
└ Selected: build → stagingPrompt Types
Select
Single choice from options:
◇ Select environment
│ ● staging
│ ○ productionTriggered by enum context fields:
context: {
env: {
from: 'flag',
schema: z.enum(['staging', 'production']),
},
}Multiselect
Multiple choices:
◆ Select features
│ ◼ TypeScript
│ ◻ ESLint
│ ◼ PrettierConfirm
Yes/no prompt:
◇ Deploy to production?
│ ● Yes / ○ NoTriggered by boolean context fields:
context: {
force: {
from: 'flag',
schema: z.boolean(),
},
}Text
Free-form input:
◇ Enter project name
│ my-awesome-projectTriggered by string context fields:
context: {
name: {
from: 'flag',
schema: z.string(),
},
}Cancellation
Pressing Ctrl+C throws a CancelError (exit code 130) so callers can decide
whether to terminate the process:
import { CancelError } from '@pokit/core';
if (p.isCancel(result)) {
throw new CancelError();
}Features
- Accessible - Screen reader support
- Keyboard navigation - Arrow keys, enter, space
- Visual feedback - Spinners, checkmarks, colors
- Graceful cancellation - Clean exit on Ctrl+C
API
createPrompter
function createPrompter(): Prompter;Returns a Prompter implementation using Clack.