Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/cliffy/prompt/mod.ts>GenericPrompt

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
class GenericPrompt
Re-export
Abstract
import { GenericPrompt } from "https://deno.land/x/cliffy@v0.19.0/prompt/mod.ts";

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.