# Promptui interactive prompts and selection for Go CLIs

> Promptui is a Go library for adding validated text prompts and searchable selection lists to command-line applications. It fits programs built with Cobra, urfave/cli, or other Go CLI frameworks, but its examples and module metadata date from an older Go toolchain era.

**manifoldco/promptui** — Interactive prompt for command-line applications

- Repository: https://github.com/manifoldco/promptui
- Website: https://www.manifold.co
- Stars: 6,406 · Forks: 343
- Language: Go
- License: BSD-3-Clause
- Published: 2026-10-16 · Updated: 2026-10-16 · Language: en
- Canonical page: https://hysenlabs.com/projects/manifoldco-promptui

## Promptui's place in a Go command-line application

Promptui addresses a specific gap between ordinary standard-library input and a full terminal user interface. A command-line program can read input from standard input without asking the library to draw labels, choices, cursors, or validation errors in the terminal. Promptui provides that interaction layer for Go programs that need a person to make a choice while the application is running.

The intended audience is Go developers building command-line applications, including projects that use spf13/cobra or urfave/cli. The README also says that Promptui can be integrated with any Go CLI application, which is broad enough to cover programs that do not use either named framework. Its origin is more specific. Manifold built it to make cloud services easier to explore through its Manifold CLI.

There are two documented input modes. `Prompt` handles a single line of text and can include live validation, confirmation, and masking. `Select` presents a list and supports pagination, search, a detailed view, and custom templates. This split keeps the library focused on common interactive decisions rather than turning it into a general terminal application framework. It is most relevant when the command has meaningful choices to collect and a human is present at the terminal.

Promptui is not a replacement for the CLI framework that parses commands, flags, or arguments. Its role begins after the application has decided that it needs interaction. That boundary matters when choosing a design: Cobra or urfave/cli can dispatch a subcommand, while Promptui can request the value needed by that subcommand.

## Prompt and Select data flow

The API is organized around two prompt structures. A `promptui.Prompt` contains display and behavior settings, and its `Run` method returns the resulting text or an error. In the README example, a validation function parses the entered value as a floating-point number and returns `errors.New("Invalid number")` when parsing fails. The application can therefore reject an invalid value during the interaction instead of accepting arbitrary text and validating it much later.

That example also demonstrates the expected error path. `prompt.Run()` returns two values, and the program checks the error before printing the selected text. Promptui therefore exposes interaction failure as part of the method contract rather than assuming every prompt can produce a result. The README mentions confirmation and masking as additional `Prompt` capabilities, but it does not provide configuration names for either feature in the shown example.

`promptui.Select` follows a related pattern with three return values from `Run`: an index, the selected item, and an error. The item values in the basic example are strings. A caller can therefore use the item for program state and still distinguish cancellation or another prompt failure through the error value.

The source layout gives these public concepts concrete supporting areas. `prompt.go`, `select.go`, `styles.go`, cursor files, key-code files, `list/`, and `screenbuf/` separate prompt types from terminal interaction and rendering. Windows-specific files appear alongside generic style and key-code files. That organization suggests platform-dependent terminal handling is part of the implementation rather than an application responsibility. The README does not document the exact rendering sequence or cancellation contract, so those details would need confirmation in GoDoc or source review before an application depends on them.

## Installing Promptui and running a first selection

The README does not give an installation command such as `go get`, so there is no documented installation step to reproduce. It does provide the module path in `go.mod`, plus complete package names used by the examples. The dependency declaration shown in the repository is:

```go
module github.com/manifoldco/promptui

go 1.12
```

An application can use the documented import path. The following is the README's basic day-selection example with its item list kept on one line so it remains within a compact tutorial block. It creates a `Select`, runs it, handles an error, and prints the returned string:

```go
package main

import (
	"fmt"

	"github.com/manifoldco/promptui"
)

func main() {
	prompt := promptui.Select{
		Label: "Select Day",
		Items: []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
			"Saturday", "Sunday"},
	}
	_, result, err := prompt.Run()
	if err != nil {
		fmt.Printf("Prompt failed %v\n", err)
		return
	}
	fmt.Printf("You choose %q\n", result)
}
```

This is a genuine interactive use, but it is not a headless workflow. Running it requires a terminal capable of presenting and receiving the interaction. For automated environments, the repository does not document a noninteractive fallback. That is a meaningful adoption boundary for CI jobs, scripts, and services that invoke a Go binary without an attached person.

The Makefile defines a `test` target for the project itself. A maintainer working from the repository can request that target, which runs the package test command with `CGO_ENABLED=0`. This is repository verification rather than application installation:

## Promptui validation, search, and terminal constraints

The strongest documented `Prompt` feature is validation at the interaction boundary. The sample uses `strconv.ParseFloat`, but the mechanism is not limited to numbers. A validation function accepts the input string and returns an error, allowing the application to define its own accepted values. The README also states that `Prompt` can mask input and request confirmation, which is useful when the collected value should not be displayed plainly or when a destructive or irreversible action needs a second decision.

`Select` is aimed at bounded choices. Its documented features include pagination, search, a detailed view, and custom templates. Pagination matters when the option list is too large for one terminal screen. Search reduces the amount of manual navigation. A detailed view can provide more context than the selectable line alone, while custom templates control how labels, items, and selected states are rendered.

These features also introduce terminal and integration questions that the short README leaves open. It does not enumerate keyboard bindings, explain screen restoration after cancellation, specify supported terminal emulators, or document how applications should behave when standard input is redirected. The source includes cursor, key-code, styling, list, and screen-buffer packages, but their names alone do not establish the full behavioral contract. An engineer embedding Promptui should consult GoDoc for those details rather than infer them from the animation or the two examples.

The library is aimed at interactive command-line programs, not general form collection. It is also not suited as the primary interface for a server, CI pipeline, or unattended migration where the set of acceptable answers can be validated outside the UI. A normal Go flag, standard input reader, or a command-specific noninteractive mode would be easier to control in those cases.

## Promptui versus flags and Cobra or urfave/cli

The clearest alternative is to keep command input in the CLI framework or Go's standard input mechanisms. Flags work well when options are known in advance, can be supplied by scripts, and should remain visible in process arguments. Standard input can read a value without drawing a terminal widget. These approaches have less visual polish than Promptui, but they are simpler to test and easier to automate.

Cobra and urfave/cli solve a different layer of the problem. The README identifies both as frameworks into which Promptui can be integrated. Cobra parses commands and flags, while Promptui can collect a selected item or validated string after a command has started. The same division applies to urfave/cli. Comparing Promptui directly with Cobra as a replacement would therefore be misleading because their responsibilities are not equivalent.

A more relevant design choice is whether the CLI should require interaction at all. Promptui is appropriate when a human should choose from a visible list, confirm an action, mask a value, or correct invalid text immediately. It is the wrong choice when output needs to be reproducible in automation, when the caller cannot provide an interactive terminal, or when values need to be passed through ordinary command arguments.

The repository also contains `example_selectwithadd_test.go`, indicating an example involving selection with addition, but the README does not explain that workflow. It should not be treated as a documented general feature without reading the example source. Similarly, the `list/` package may be useful for direct reuse, but the README directs readers to GoDoc for its complete public interface.

## Promptui maintenance, dependencies, and upgrade cost

The repository is not archived, and its last push was on 2026-10-13. The recent push date and the older release date should be considered separately, but the latest listed release is v0.9.0 from 2021-10-30. A recent repository push does not itself establish that a new release has shipped, so adopters should distinguish source activity from versioned dependency availability.

The module declares `go 1.12`. Its listed dependencies include `github.com/chzyer/readline`, `github.com/chzyer/logex`, `github.com/chzyer/test`, and `golang.org/x/sys`, with several entries marked indirect. The old Go directive and pinned historical dependency versions make dependency review part of the adoption decision. The Makefile's lint bootstrap installs `golangci-lint` version `v1.21.0`, which is also an older project-specific tool choice.

Promptui is licensed under BSD-3-Clause. The repository provides `LICENSE.md`, and the README links to it. The license permits use and modification under its stated conditions, but redistribution, notices, and source obligations should be checked in the actual license file for the intended distribution. This is a compliance check, not legal advice.

Upgrade cost is likely to involve more than changing the import path. A new application must confirm compatibility with its current Go version, inspect the dependency graph, and test keyboard input and rendering on its supported platforms. The repository includes Windows-specific files, but the README does not publish a support matrix. Those checks are more important than treating the recent push as proof of compatibility with every modern terminal environment.

## Conclusion

Adopt Promptui when a Go CLI needs an interactive text prompt or selectable list and its terminal-oriented API matches the application. Do not assume it is suitable for web forms, noninteractive automation, or a current dependency baseline without checking the UI behavior and resolving the older Go 1.12 module requirements first. For a new application, verify whether Promptui still matches the target Go version and whether its BSD-3-Clause terms fit the distribution model before adding it.

## FAQ

### What is Promptui used for in a Go CLI?

Promptui provides interactive command-line prompts for Go applications. Its two documented modes are single-line `Prompt` input and list-based `Select` input.

### Does Promptui support validating text entered by the user?

Yes. `Prompt` supports live validation, and the README demonstrates a function that parses input as a floating-point number and returns an error for invalid text.

### Can Promptui be used with Cobra or urfave/cli?

Yes. The README specifically names spf13/cobra and urfave/cli as supported integration targets, and it also says Promptui can be used with other Go CLI applications.

## Sources

- [License: BSD-3-Clause](https://github.com/manifoldco/promptui/blob/master/LICENSE)
- [manifoldco/promptui on GitHub](https://github.com/manifoldco/promptui)
- [Project website](https://www.manifold.co)
- [README](https://github.com/manifoldco/promptui/blob/master/README.md)
- [Releases](https://github.com/manifoldco/promptui/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/manifoldco-promptui
