No description
  • Go 98.3%
  • Makefile 1.7%
Find a file
2019-01-01 22:01:46 -08:00
.github Create listbot.md 2017-11-16 15:32:02 -04:00
_examples Improved documentation further and the SelectWithAdd example 2018-07-19 11:45:46 -04:00
list Improved documentation further and the SelectWithAdd example 2018-07-19 11:45:46 -04:00
screenbuf Improved documentation further and the SelectWithAdd example 2018-07-19 11:45:46 -04:00
.gitignore Add go dep 2017-10-16 14:36:42 -04:00
.travis.yml Use go modules when building on go 1.11.x 2018-11-26 10:54:48 -04:00
CHANGELOG.md Release 0.3.2 2018-11-26 11:03:28 -04:00
CODE_OF_CONDUCT.md Add initial CODE_OF_CONDUCT.md 2017-10-16 13:35:25 -03:00
codes.go Improved documentation further and the SelectWithAdd example 2018-07-19 11:45:46 -04:00
codes_test.go Custom style/output for prompt and select (#8) 2017-10-19 20:50:57 -04:00
cursor.go attemp II at making the checker happy, actually ran the makefile this time 2019-01-01 22:01:46 -08:00
cursor_test.go Add support for ← and → in editable fields 2019-01-01 16:41:15 -08:00
example_main_test.go New doc fixes 2018-07-20 14:07:37 -04:00
example_prompt_test.go Gofmt'd the whole project 2018-07-19 14:06:31 -04:00
example_select_test.go Gofmt'd the whole project 2018-07-19 14:06:31 -04:00
example_selectwithadd_test.go Improved documentation further and the SelectWithAdd example 2018-07-19 11:45:46 -04:00
go.mod Use go modules when building on go 1.11.x 2018-11-26 10:54:48 -04:00
go.sum Use go modules when building on go 1.11.x 2018-11-26 10:54:48 -04:00
Gopkg.lock Update dep after juju/ansiterm fix (#51) 2017-12-12 15:54:06 -05:00
Gopkg.toml fix typo in Gopkg.toml (#50) 2017-12-12 15:41:45 -05:00
keycodes.go Change description for navigation keys for Windows (#74) 2018-07-26 08:37:04 -04:00
keycodes_windows.go Change description for navigation keys for Windows (#74) 2018-07-26 08:37:04 -04:00
LICENSE.md Add initial LICENSE.md 2017-10-16 13:35:23 -03:00
Makefile Use go modules when building on go 1.11.x 2018-11-26 10:54:48 -04:00
prompt.go Add support for ← and → in editable fields 2019-01-01 16:41:15 -08:00
promptui.go Improved documentation further and the SelectWithAdd example 2018-07-19 11:45:46 -04:00
README.md Release v0.2.1 (#30) 2017-11-30 11:26:18 -04:00
select.go Add support for ← and → in editable fields 2019-01-01 16:41:15 -08:00
select_test.go Prompt improve default value (#21) 2017-11-02 09:48:02 -04:00
styles.go Gofmt'd the whole project 2018-07-19 14:06:31 -04:00
styles_windows.go New doc fixes 2018-07-20 14:07:37 -04:00
tools.go Use go modules when building on go 1.11.x 2018-11-26 10:54:48 -04:00

promptui

Interactive prompt for command-line applications.

We built Promptui because we wanted to make it easy and fun to explore cloud services with manifold cli.

Code of Conduct | Contribution Guidelines

GitHub release GoDoc Travis Go Report Card License

Overview

promptui

Promptui is a library providing a simple interface to create command-line prompts for go. It can be easily integrated into spf13/cobra, urfave/cli or any cli go application.

Promptui has two main input modes:

  • Prompt provides a single line for user input. Prompt supports optional live validation, confirmation and masking the input.

  • Select provides a list of options to choose from. Select supports pagination, search, detailed view and custom templates.

For a full list of options check GoDoc.

Basic Usage

Prompt

package main

import (
	"errors"
	"fmt"
	"strconv"

	"github.com/manifoldco/promptui"
)

func main() {
	validate := func(input string) error {
		_, err := strconv.ParseFloat(input, 64)
		if err != nil {
			return errors.New("Invalid number")
		}
		return nil
	}

	prompt := promptui.Prompt{
		Label:    "Number",
		Validate: validate,
	}

	result, err := prompt.Run()

	if err != nil {
		fmt.Printf("Prompt failed %v\n", err)
		return
	}

	fmt.Printf("You choose %q\n", result)
}

Select

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)
}

More Examples

See full list of examples