prompt

package
v6.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package prompt asks questions on a terminal. Ctrl-C ends the process with 130 and without a stack trace, as the TypeScript CLI's prompts did.

Index

Constants

This section is empty.

Variables

View Source
var Interactive = func() bool { return term.IsTerminal(int(os.Stdout.Fd())) }

Interactive reports whether a question would be seen: stdout is a terminal. Tests replace it.

Functions

func Confirm

func Confirm(message string, defaultYes, nonInteractive bool) (bool, error)

Confirm asks a yes/no question. When stdout is not a terminal, as in a pipeline or with output redirected to a file, nobody would see the question, and it answers nonInteractive. This is the TypeScript CLI's check, so the same invocations ask as before.

func HTTPURL

func HTTPURL(value string) error

func Input

func Input(message, defaultValue string, validate Validator) (string, error)

Input asks until the answer is valid. An empty answer takes the default.

func NotBlank

func NotBlank(value string) error

func Password

func Password(message string, validate Validator) (string, error)

Password reads without echo when stdin is a terminal.

func UseInput

func UseInput(r io.Reader)

UseInput reads answers from r instead of the terminal. Tests script a dialogue with it.

Types

type Validator

type Validator func(string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL