Skip to content

Prompts

The @clack/prompts package provides a collection of pre-built, high-level prompts that make it easy to create interactive command-line interfaces. It builds on top of the core package to provide a more developer-friendly experience.

Key Features

  • Pre-built prompts: Ready-to-use prompt components
  • Consistent styling: Unified look and feel across all prompts
  • Type-safe: Full TypeScript support
  • Customizable: Easy to extend and modify

Available Prompts

Text Input

import {
const text: (opts: TextOptions) => Promise<string | symbol>
text
} from '@clack/prompts';
const
const name: string | symbol
name
= await
function text(opts: TextOptions): Promise<string | symbol>
text
({
TextOptions.message: string
message
: 'What is your name?',
TextOptions.placeholder?: string
placeholder
: 'John Doe',
TextOptions.validate?: (value: string) => string | Error | undefined
validate
: (
value: string
value
) => {
if (
value: string
value
.
String.length: number

Returns the length of a String object.

length
< 2) return 'Name must be at least 2 characters';
return
var undefined
undefined
;
},
});

  What is your name?
  John Doe

Password Input

import {
const password: (opts: PasswordOptions) => Promise<string | symbol>
password
} from '@clack/prompts';
const
const secret: string | symbol
secret
= await
function password(opts: PasswordOptions): Promise<string | symbol>
password
({
PasswordOptions.message: string
message
: 'What is your password?',
PasswordOptions.mask?: string
mask
: '*',
PasswordOptions.validate?: (value: string) => string | Error | undefined
validate
: (
value: string
value
) => {
if (
value: string
value
.
String.length: number

Returns the length of a String object.

length
< 8) return 'Your password must be at least 8 characters';
if (!/[A-Z]/.
RegExp.test(string: string): boolean

Returns a Boolean value that indicates whether or not a pattern exists in a searched string.

@paramstring String on which to perform the search.

test
(
value: string
value
)) return 'Your password must be least contain 1 uppercase letter';
if (!/[0-9]/.
RegExp.test(string: string): boolean

Returns a Boolean value that indicates whether or not a pattern exists in a searched string.

@paramstring String on which to perform the search.

test
(
value: string
value
)) return 'Your password must be least contain 1 number';
if (!/[*?!@&]/.
RegExp.test(string: string): boolean

Returns a Boolean value that indicates whether or not a pattern exists in a searched string.

@paramstring String on which to perform the search.

test
(
value: string
value
)) return 'Your password must be least contain 1 special characters (*?!@&)';
return
var undefined
undefined
;
},
});

  What is your password?
  *****_

Selection

Simple value

import {
const select: <Value>(opts: SelectOptions<Value>) => Promise<symbol | Value>
select
} from '@clack/prompts';
const
const framework: symbol | "next" | "astro" | "svelte"
framework
= await
select<"next" | "astro" | "svelte">(opts: SelectOptions<"next" | "astro" | "svelte">): Promise<symbol | "next" | "astro" | "svelte">
select
({
SelectOptions<Value>.message: string
message
: 'Pick a framework',
SelectOptions<"next" | "astro" | "svelte">.options: ({
value: "next";
label?: string;
hint?: string;
} | {
value: "astro";
label?: string;
hint?: string;
} | {
value: "svelte";
label?: string;
hint?: string;
})[]
options
: [
{
value: "next"

Internal data for this option.

value
: 'next',
label?: string

The optional, user-facing text for this option.

By default, the value is converted to a string.

label
: 'Next.js' },
{
value: "astro"

Internal data for this option.

value
: 'astro',
label?: string

The optional, user-facing text for this option.

By default, the value is converted to a string.

label
: 'Astro' },
{
value: "svelte"

Internal data for this option.

value
: 'svelte',
label?: string

The optional, user-facing text for this option.

By default, the value is converted to a string.

label
: 'SvelteKit' },
],
});

  Pick a framework
   Next.js
  ○ Astro
  ○ SvelteKit

Complex value

import {
const select: <Value>(opts: SelectOptions<Value>) => Promise<symbol | Value>
select
} from '@clack/prompts';
const
const framework: symbol | {
framework: string;
language: string;
} | {
framework: null;
language: string;
}
framework
= await
select<{
framework: string;
language: string;
} | {
framework: null;
language: string;
}>(opts: SelectOptions<{
framework: string;
language: string;
} | {
framework: null;
language: string;
}>): Promise<...>
select
({
SelectOptions<Value>.message: string
message
: 'Pick a framework',
SelectOptions<{ framework: string; language: string; } | { framework: null; language: string; }>.options: ({
value: {
framework: string;
language: string;
};
label: string;
hint?: string;
} | {
value: {
framework: null;
language: string;
};
label: string;
hint?: string;
})[]
options
: [
{
value: {
framework: string;
language: string;
}
value
: {
framework: string
framework
: 'Next',
language: string
language
: 'React' },
label: string

Required. The user-facing text for this option.

label
: 'Next.js' },
{
value: {
framework: null;
language: string;
}
value
: {
framework: null
framework
: null,
language: string
language
: 'Astro' },
label: string

Required. The user-facing text for this option.

label
: 'Astro' },
{
value: {
framework: string;
language: string;
}
value
: {
framework: string
framework
: 'Sveltekit',
language: string
language
: 'Svelte' },
label: string

Required. The user-facing text for this option.

label
: 'SvelteKit' },
],
});

  Pick a framework
   Next.js
  ○ Astro
  ○ SvelteKit

Multiple values

import {
const multiselect: <Value>(opts: MultiSelectOptions<Value>) => Promise<symbol | Value[]>
multiselect
} from '@clack/prompts';
const
const framework: symbol | ({
framework: string;
language: string;
} | {
framework: null;
language: string;
})[]
framework
= await
multiselect<{
framework: string;
language: string;
} | {
framework: null;
language: string;
}>(opts: MultiSelectOptions<{
framework: string;
language: string;
} | {
framework: null;
language: string;
}>): Promise<...>
multiselect
({
MultiSelectOptions<Value>.message: string
message
: 'Pick a framework',
MultiSelectOptions<{ framework: string; language: string; } | { framework: null; language: string; }>.options: ({
value: {
framework: string;
language: string;
};
label: string;
hint?: string;
} | {
value: {
framework: null;
language: string;
};
label: string;
hint?: string;
})[]
options
: [
{
value: {
framework: string;
language: string;
}
value
: {
framework: string
framework
: 'Next',
language: string
language
: 'React' },
label: string

Required. The user-facing text for this option.

label
: 'Next.js' },
{
value: {
framework: null;
language: string;
}
value
: {
framework: null
framework
: null,
language: string
language
: 'Astro' },
label: string

Required. The user-facing text for this option.

label
: 'Astro' },
{
value: {
framework: string;
language: string;
}
value
: {
framework: string
framework
: 'Sveltekit',
language: string
language
: 'Svelte' },
label: string

Required. The user-facing text for this option.

label
: 'SvelteKit' },
],
});

  Pick a framework
   Next.js
   Astro
  ◻ SvelteKit

Confirmation

import {
const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>
confirm
} from '@clack/prompts';
const
const shouldProceed: boolean | symbol
shouldProceed
= await
function confirm(opts: ConfirmOptions): Promise<boolean | symbol>
confirm
({
ConfirmOptions.message: string
message
: 'Do you want to continue?',
});

  Do you want to continue?
   Yes / ○ No

Grouping

Group Multiselect

import {
const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<symbol | Value[]>
groupMultiselect
} from '@clack/prompts';
const
const projectOptions: symbol | ("Jest" | "Playwright" | "Vitest" | "js" | "ts" | "coffee" | "Prettier" | "ESLint" | "Biome.js")[]
projectOptions
= await
groupMultiselect<"Jest" | "Playwright" | "Vitest" | "js" | "ts" | "coffee" | "Prettier" | "ESLint" | "Biome.js">(opts: GroupMultiSelectOptions<"Jest" | "Playwright" | "Vitest" | "js" | "ts" | "coffee" | "Prettier" | "ESLint" | "Biome.js">): Promise<...>
groupMultiselect
({
GroupMultiSelectOptions<Value>.message: string
message
: 'Define your project',
GroupMultiSelectOptions<"Jest" | "Playwright" | "Vitest" | "js" | "ts" | "coffee" | "Prettier" | "ESLint" | "Biome.js">.options: Record<string, ({
value: "Jest";
label?: string;
hint?: string;
} | {
value: "Playwright";
label?: string;
hint?: string;
} | {
value: "Vitest";
label?: string;
hint?: string;
} | {
value: "js";
label?: string;
hint?: string;
} | ... 4 more ... | {
...;
})[]>
options
: {
'Testing': [
{
value: "Jest"

Internal data for this option.

value
: 'Jest' },
{
value: "Playwright"

Internal data for this option.

value
: 'Playwright' },
{
value: "Vitest"

Internal data for this option.

value
: 'Vitest' },
],
'Language': [{
label?: string

The optional, user-facing text for this option.

By default, the value is converted to a string.

label
: "Javascript",
value: "js"

Internal data for this option.

value
: 'js',
}, {
label?: string

The optional, user-facing text for this option.

By default, the value is converted to a string.

label
: 'TypeScript',
value: "ts"

Internal data for this option.

value
: 'ts',
}, {
label?: string

The optional, user-facing text for this option.

By default, the value is converted to a string.

label
: "CoffeeScript",
value: "coffee"

Internal data for this option.

value
: 'coffee',
}],
'Code quality': [
{
value: "Prettier"

Internal data for this option.

value
: 'Prettier' },
{
value: "ESLint"

Internal data for this option.

value
: 'ESLint' },
{
value: "Biome.js"

Internal data for this option.

value
: 'Biome.js' },
],
},
});

  Define your project
   Testing
 Jest
 Playwright
 Vitest
   Language
 Javascript
 TypeScript
 CoffeeScript
  ◻ Code quality
  │ ◻ Prettier
  │ ◻ ESLint
 Biome.js

Group

The group function provides a convenient API for combining a series of questions. Each question receives the results of previous answers. The group function returns an object containing the result of every question.

import {
const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T> | undefined) => Promise<{ [P in keyof PromptGroupAwaitedReturn<T>]: PromptGroupAwaitedReturn<T>[P]; }>

Define a group of prompts to be displayed and return a results of objects within the group

group
,
const text: (opts: TextOptions) => Promise<string | symbol>
text
,
const password: (opts: PasswordOptions) => Promise<string | symbol>
password
} from '@clack/prompts';
const
const account: {
email: string;
username: unknown;
password: string;
}
account
= await
group<{
email: string | symbol;
username: unknown;
password: string | symbol;
}>(prompts: PromptGroup<{
email: string | symbol;
username: unknown;
password: string | symbol;
}>, opts?: PromptGroupOptions<{
email: string | symbol;
username: unknown;
password: string | symbol;
}> | undefined): Promise<...>

Define a group of prompts to be displayed and return a results of objects within the group

group
({
email: (opts: {
results: {
username?: unknown;
password?: string;
};
}) => Promise<string | symbol | undefined> | undefined
email
: () =>
function text(opts: TextOptions): Promise<string | symbol>
text
({
TextOptions.message: string
message
: 'What is your email address?',
TextOptions.validate?: (value: string) => string | Error | undefined
validate
: (
value: string
value
) => {
if (!/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]{2,}$/i.
RegExp.test(string: string): boolean

Returns a Boolean value that indicates whether or not a pattern exists in a searched string.

@paramstring String on which to perform the search.

test
(
value: string
value
)) return 'Please enter a valid email'
}
}),
username: (opts: {
results: {
email?: string;
password?: string;
};
}) => Promise<unknown> | undefined
username
: ({
results: {
email?: string;
password?: string;
}
results
}) =>
function text(opts: TextOptions): Promise<string | symbol>
text
({
TextOptions.message: string
message
: 'What is your username?',
TextOptions.placeholder?: string
placeholder
:
results: {
email?: string;
password?: string;
}
results
.
email?: string | undefined
email
?.
String.replace(searchValue: string | RegExp, replaceValue: string): string (+3 overloads)

Replaces text in a string, using a regular expression or search string.

@paramsearchValue A string or regular expression to search for.

@paramreplaceValue A string containing the text to replace. When the {@linkcode searchValue} is a RegExp, all matches are replaced if the g flag is set (or only those matches at the beginning, if the y flag is also present). Otherwise, only the first match of {@linkcode searchValue} is replaced.

replace
(/@.+$/, '').
String.toLowerCase(): string

Converts all the alphabetic characters in a string to lowercase.

toLowerCase
() ?? '',
TextOptions.validate?: (value: string) => string | Error | undefined
validate
: (
value: string
value
) => {
// FOR DEMO PURPOSES ONLY! Use a robust validation library in production
if (
value: string
value
.
String.length: number

Returns the length of a String object.

length
< 2) return 'Please enter at least 2 characters'
}
}),
password: (opts: {
results: {
email?: string;
username?: unknown;
};
}) => Promise<string | symbol | undefined> | undefined
password
: () =>
function password(opts: PasswordOptions): Promise<string | symbol>
password
({
PasswordOptions.message: string
message
: 'Define your password'
}),
});

  What is your email address?
  user.name@example.com

  What is your username?
  bomb_sh

  Define your password
  ▪▪▪▪▪▪▪▪▪▪▪▪_

Tasks

The tasks function provides a convenient API for sequencing several asynchronous actions one after the other.

import {
const tasks: (tasks: Task[]) => Promise<void>

Define a group of tasks to be executed

tasks
} from "@clack/prompts";
await
function tasks(tasks: Task[]): Promise<void>

Define a group of tasks to be executed

tasks
([
{
title: string

Task title

title
: 'Downloading package',
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>

Task function

task
: async () => {
// Do a fetch
return 'Download completed';
},
},
{
title: string

Task title

title
: "Un-archiving",
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>

Task function

task
: async (
message: (string: string) => void
message
) => {
const
const parts: string[]
parts
:
interface Array<T>
Array
<string> = [/* ... */];
for (let
let index: number
index
= 0;
let index: number
index
<
const parts: string[]
parts
.
Array<T>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
;
let index: number
index
++) {
const
const type: string
type
=
const parts: string[]
parts
[
let index: number
index
];
// Update the message to indicate what is done
message: (string: string) => void
message
(`Un-archiving ${
const type: string
type
} (${
let index: number
index
+ 1}/${
const parts: string[]
parts
.
Array<T>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
})`);
// Do the un-archiving task
}
return 'Un-archiving completed';
},
},
{
title: string

Task title

title
: 'Linking',
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>

Task function

task
: async () => {
// Do work
return 'Package linked';
},
},
]);

  Download completed

  Un-archiving lib (2/3)..

Support functions

Intro

The intro function defines the beginning of an interaction. It accepts an optional string parameter which is displayed as a title for the interaction.

import {
const intro: (title?: string) => void
intro
} from '@clack/prompts';
function intro(title?: string): void
intro
('Welcome to clack');
  Welcome to clack

Outro

The outro function defines the end of an interaction. It accepts an optional string parameter which is displayed as a concluding message.

import {
const outro: (message?: string) => void
outro
} from '@clack/prompts';
function outro(message?: string): void
outro
('All operations are finished');

  All operations are finished
 

Cancel

The cancel function defines an interruption of an interaction and therefore its end. It accepts an optional string parameter which is displayed as a cancellation message.

import {
const cancel: (message?: string) => void
cancel
} from '@clack/prompts';
function cancel(message?: string): void
cancel
('Installation canceled');
  Installation canceled
 

Spinner

import {
const spinner: ({ indicator }?: SpinnerOptions) => {
start: (msg?: string) => void;
stop: (msg?: string, code?: number) => void;
message: (msg?: string) => void;
}
spinner
} from '@clack/prompts';
const
const spin: {
start: (msg?: string) => void;
stop: (msg?: string, code?: number) => void;
message: (msg?: string) => void;
}
spin
=
function spinner({ indicator }?: SpinnerOptions): {
start: (msg?: string) => void;
stop: (msg?: string, code?: number) => void;
message: (msg?: string) => void;
}
spinner
();
const spin: {
start: (msg?: string) => void;
stop: (msg?: string, code?: number) => void;
message: (msg?: string) => void;
}
spin
.
start: (msg?: string) => void
start
('Loading');
// Do something
const spin: {
start: (msg?: string) => void;
stop: (msg?: string, code?: number) => void;
message: (msg?: string) => void;
}
spin
.
message: (msg?: string) => void
message
('Finishing');
// Do more things
const spin: {
start: (msg?: string) => void;
stop: (msg?: string, code?: number) => void;
message: (msg?: string) => void;
}
spin
.
stop: (msg?: string, code?: number) => void
stop
('Done');

  Loading...

The second parameter of spinner.stop (code) allow you to indicate the ending status of the spinner:

  • 0 (or no value) indicate a success and the symbol for a finished task will be used
  • 1 indicate a cancellation and the red square symbol will be used
  • Any other code indicate an error and the yellow triangle symbol will be used

Note

The note function renders a box around a message to draw a user’s attention. This is useful for displaying next steps and linking to your documentation towards the end of an interaction.

import {
const note: (message?: string, title?: string) => void
note
} from '@clack/prompts';
function note(message?: string, title?: string): void
note
(
'You can edit the file src/index.jsx',
'Next steps.'
);

  Next steps. ─────────────────────────╮
                                       
  You can edit the file src/index.jsx  
                                       
├───────────────────────────────────────╯

The second parameter (the title) is optional

import {
const note: (message?: string, title?: string) => void
note
} from '@clack/prompts';
function note(message?: string, title?: string): void
note
(
'All files have been created.',
);

   ─────────────────────────────╮
                                
  All files have been created.  
                                
├────────────────────────────────╯

Logs

The log utilities allow you to add semantic contextual information during an interaction. Each function renders with specific styling to communicate status.

log is an object containing the following methods:

  • log.message displays a message without any symbols to communicate state
  • log.info displays a message with a neutral state
  • log.warn (alias log.warning) displays a message with a caution state
  • log.error displays a message with a danger state
  • log.success displays a message with a success state
  • log.step displays a message with a neutral, completed state
import {
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
} from '@clack/prompts';
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
message: (message?: string, { symbol }?: LogMessageOptions) => void
message
('Entering directory "src"');
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
info: (message: string) => void
info
('No files to update');
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
warn: (message: string) => void
warn
('Directory is empty, skipping');
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
warning: (message: string) => void

alias for log.warn().

warning
('Directory is empty, skipping');
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
error: (message: string) => void
error
('Permission denied on file src/secret.js');
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
success: (message: string) => void
success
('Installation complete');
const log: {
message: (message?: string, { symbol }?: LogMessageOptions) => void;
info: (message: string) => void;
success: (message: string) => void;
step: (message: string) => void;
warn: (message: string) => void;
warning: (message: string) => void;
error: (message: string) => void;
}
log
.
step: (message: string) => void
step
('Check files');

  Entering directory “src”

  No files to update

  Directory is empty, skipping

  Directory is empty, skipping

  Permission denied on file src/secret.js

  Installation complete

  Check files

Stream

The stream utilities allow you, like the log utilities, to add semantic contextual information during an interaction, expect that the message contains an unknown number of lines. Each function renders with specific styling to communicate status.

import {
const stream: {
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
... 4 more ...;
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
}
stream
} from "@clack/prompts";
import * as
module "node:fs"
fs
from "node:fs";
await
const stream: {
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
... 4 more ...;
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
}
stream
.
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>
message
(
module "node:fs"
fs
.
function createReadStream(path: fs.PathLike, options?: BufferEncoding | ReadStreamOptions): fs.ReadStream

options can include start and end values to read a range of bytes from the file instead of the entire file. Both start and end are inclusive and start counting at 0, allowed values are in the [0, Number.MAX_SAFE_INTEGER] range. If fd is specified and start is omitted or undefined, fs.createReadStream() reads sequentially from the current file position. The encoding can be any one of those accepted by Buffer.

If fd is specified, ReadStream will ignore the path argument and will use the specified file descriptor. This means that no 'open' event will be emitted. fd should be blocking; non-blocking fds should be passed to net.Socket.

If fd points to a character device that only supports blocking reads (such as keyboard or sound card), read operations do not finish until data is available. This can prevent the process from exiting and the stream from closing naturally.

By default, the stream will emit a 'close' event after it has been destroyed. Set the emitClose option to false to change this behavior.

By providing the fs option, it is possible to override the corresponding fs implementations for open, read, and close. When providing the fs option, an override for read is required. If no fd is provided, an override for open is also required. If autoClose is true, an override for close is also required.

import { createReadStream } from 'node:fs';
// Create a stream from some character device.
const stream = createReadStream('/dev/input/event0');
setTimeout(() => {
stream.close(); // This may not close the stream.
// Artificially marking end-of-stream, as if the underlying resource had
// indicated end-of-file by itself, allows the stream to close.
// This does not cancel pending read operations, and if there is such an
// operation, the process may still not be able to exit successfully
// until it finishes.
stream.push(null);
stream.read(0);
}, 100);

If autoClose is false, then the file descriptor won't be closed, even if there's an error. It is the application's responsibility to close it and make sure there's no file descriptor leak. If autoClose is set to true (default behavior), on 'error' or 'end' the file descriptor will be closed automatically.

mode sets the file mode (permission and sticky bits), but only if the file was created.

An example to read the last 10 bytes of a file which is 100 bytes long:

import { createReadStream } from 'node:fs';
createReadStream('sample.txt', { start: 90, end: 99 });

If options is a string, then it specifies the encoding.

@sincev0.1.31

createReadStream
('./banner.txt', {
StreamOptions.encoding?: BufferEncoding | undefined
encoding
: 'utf-8' }));
await
const stream: {
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
... 4 more ...;
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
}
stream
.
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>
info
((async function*() {
yield 'Open file...';
// Open file
yield ' \x1b[32mOK\x1b[39m\n';
yield 'Parsing file...';
// Parse data
yield ' \x1b[32mOK\x1b[39m';
return;
})());
await
const stream: {
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
... 4 more ...;
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
}
stream
.
step: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>
step
([
'Job1...',
' \x1b[32mdone\x1b[39m\n',
'Job2...',
' \x1b[32mdone\x1b[39m\n',
'Job3...',
' \x1b[32mdone\x1b[39m',
]);


  ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣶⣿⣿⣿⣿⣿⣿⣶⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀
  ⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⣀⠀⠀⠀⠀⣿⣿⣿⡿⠀⠀⠀⠀⣀⠀
  ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⢠⣿⣿⣶⣤⣄⣻⣿⣿⣇⣠⣴⣶⣿⣿⡀
  ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⢾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡧
  ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠉⢉⣿⣿⣿⣿⣿⣯⡉⠉⠀⠀⠀
  ⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⠟⢻⣿⣿⣿⣦⠀⠀⠀
  ⠀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠐⠿⣿⣿⣿⠏⠀⠀⢻⣿⣿⣿⠷⠀⠀
  ⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠏⠀⠀⠀⠀⠹⠋⠁⠀⠀⠀
  ⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⢿⣿⣿⣿⣿⡿⠿⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀


  Open file... OK
  Parsing file... OK

  Job1... done
  Job2... done
  Job3... done

Installation

Terminal window
npm install @clack/prompts

Usage

The prompts package is designed to be intuitive and easy to use. Each prompt function returns a Promise that resolves to the user’s input.

For more detailed examples and advanced usage patterns, check out our examples guide and best practices.