• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H11-Jan-2020-8050

_examples/H11-Jan-2020-303233

list/H11-Jan-2020-403294

screenbuf/H11-Jan-2020-287238

.gitignoreH A D11-Jan-202026 43

.golangci.ymlH A D11-Jan-2020437 2723

.travis.ymlH A D11-Jan-2020260 1511

CHANGELOG.mdH A D11-Jan-20202.1 KiB11062

CODE_OF_CONDUCT.mdH A D11-Jan-20203.1 KiB7456

LICENSE.mdH A D11-Jan-20201.5 KiB3023

MakefileH A D11-Jan-20201.2 KiB5031

README.mdH A D11-Jan-20202.6 KiB10876

codes.goH A D11-Jan-20202.8 KiB12185

codes_test.goH A D11-Jan-2020791 3126

cursor.goH A D11-Jan-20205.3 KiB221149

cursor_test.goH A D11-Jan-20202.6 KiB10489

example_main_test.goH A D11-Jan-20201.2 KiB5538

example_prompt_test.goH A D11-Jan-20201,018 4228

example_select_test.goH A D11-Jan-20202.5 KiB7654

example_selectwithadd_test.goH A D11-Jan-2020657 3424

go.modH A D11-Jan-2020647 1714

go.sumH A D11-Jan-20202.2 KiB2423

keycodes.goH A D11-Jan-20201,020 3214

keycodes_windows.goH A D11-Jan-2020993 3013

prompt.goH A D11-Jan-20208.4 KiB334216

promptui.goH A D11-Jan-20201 KiB286

select.goH A D11-Jan-202017.4 KiB638393

select_test.goH A D11-Jan-20204 KiB169141

styles.goH A D11-Jan-2020855 248

styles_windows.goH A D11-Jan-2020846 228

README.md

1# promptui
2
3Interactive prompt for command-line applications.
4
5We built Promptui because we wanted to make it easy and fun to explore cloud
6services with [manifold cli](https://github.com/manifoldco/manifold-cli).
7
8[Code of Conduct](./CODE_OF_CONDUCT.md) |
9[Contribution Guidelines](./.github/CONTRIBUTING.md)
10
11[![GitHub release](https://img.shields.io/github/tag/manifoldco/promptui.svg?label=latest)](https://github.com/manifoldco/promptui/releases)
12[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/manifoldco/promptui)
13[![Travis](https://img.shields.io/travis/manifoldco/promptui/master.svg)](https://travis-ci.org/manifoldco/promptui)
14[![Go Report Card](https://goreportcard.com/badge/github.com/manifoldco/promptui)](https://goreportcard.com/report/github.com/manifoldco/promptui)
15[![License](https://img.shields.io/badge/license-BSD-blue.svg)](./LICENSE.md)
16
17## Overview
18
19![promptui](https://media.giphy.com/media/xUNda0Ngb5qsogLsBi/giphy.gif)
20
21Promptui is a library providing a simple interface to create command-line
22prompts for go. It can be easily integrated into
23[spf13/cobra](https://github.com/spf13/cobra),
24[urfave/cli](https://github.com/urfave/cli) or any cli go application.
25
26Promptui has two main input modes:
27
28- `Prompt` provides a single line for user input. Prompt supports
29  optional live validation, confirmation and masking the input.
30
31- `Select` provides a list of options to choose from. Select supports
32  pagination, search, detailed view and custom templates.
33
34For a full list of options check [GoDoc](https://godoc.org/github.com/manifoldco/promptui).
35
36## Basic Usage
37
38### Prompt
39
40```go
41package main
42
43import (
44	"errors"
45	"fmt"
46	"strconv"
47
48	"github.com/manifoldco/promptui"
49)
50
51func main() {
52	validate := func(input string) error {
53		_, err := strconv.ParseFloat(input, 64)
54		if err != nil {
55			return errors.New("Invalid number")
56		}
57		return nil
58	}
59
60	prompt := promptui.Prompt{
61		Label:    "Number",
62		Validate: validate,
63	}
64
65	result, err := prompt.Run()
66
67	if err != nil {
68		fmt.Printf("Prompt failed %v\n", err)
69		return
70	}
71
72	fmt.Printf("You choose %q\n", result)
73}
74```
75
76### Select
77
78```go
79package main
80
81import (
82	"fmt"
83
84	"github.com/manifoldco/promptui"
85)
86
87func main() {
88	prompt := promptui.Select{
89		Label: "Select Day",
90		Items: []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
91			"Saturday", "Sunday"},
92	}
93
94	_, result, err := prompt.Run()
95
96	if err != nil {
97		fmt.Printf("Prompt failed %v\n", err)
98		return
99	}
100
101	fmt.Printf("You choose %q\n", result)
102}
103```
104
105### More Examples
106
107See full list of [examples](https://github.com/manifoldco/promptui/tree/master/_examples)
108