Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
class Cliffy.GenericPrompt
Re-export
Abstract
import { Cliffy } from "https://deno.land/x/dmm@v2.1.2/tests/integration/up-to-date-deps/original_deps.ts";
const { GenericPrompt } = Cliffy;

Generic prompt representation.

Constructors

new
protected
GenericPrompt(settings: S)

Properties

protected
readonly
cursor: Cursor
protected
readonly
indent: string
protected
readonly
settings: S
protected
readonly
tty

Methods

protected
optional
body(): string | undefined | Promise<string | undefined>
protected
clear(): void

Clear prompt output.

protected
defaults(): string
protected
error(): string | undefined
protected
abstract
format(value: T): string

Format output value.

protected
abstract
getValue(): V

Get input value.

protected
handleEvent(event: KeyCode): Promise<void>

Handle user input event.

protected
hint(): string | undefined
protected
isKey<K extends unknown, N extends keyof K>(
keys: K | undefined,
name: N,
event: KeyCode,
): boolean

Check if key event has given name or sequence.

protected
message(): string
protected
read(): Promise<boolean>

Read user input from stdin, handle events and validate user input.

protected
render(): Promise<void>

Render prompt.

protected
submit(): Promise<void>
protected
success(value: T): string | undefined

Get prompt success message.

protected
abstract
transform(value: V): T | undefined

Map input value to output value.

protected
abstract
validate(value: V): ValidateResult

Validate input value.

prompt(): Promise<T>

Execute the prompt and show cursor on end.

Static Properties

protected
injectedValue: unknown | undefined

Static Methods

inject(value: unknown): void

Inject prompt value. Can be used for unit tests or pre selections.