1
0
mirror of https://github.com/strongdm/comply synced 2024-07-03 07:24:22 +00:00
comply/vendor/github.com/manifoldco/promptui
Justin McCarthy 7468711b3b
go.mod: update gitlab dep to v0.30.1
Releases after github.com/xanzy/go-gitlab@v0.31.0 introduce breaking
changes to the NewClient call.

Addresses #94
2020-09-14 11:31:56 -07:00
..
list go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
screenbuf go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
.gitignore go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
.golangci.yml go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
.travis.yml go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
CHANGELOG.md go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
CODE_OF_CONDUCT.md Initial commit 2018-05-15 14:13:11 -07:00
codes.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
cursor.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
go.mod go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
go.sum go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
keycodes_windows.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
keycodes.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
LICENSE.md Initial commit 2018-05-15 14:13:11 -07:00
Makefile go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
prompt.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
promptui.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
README.md go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
select.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
styles_windows.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07:00
styles.go go.mod: update gitlab dep to v0.30.1 2020-09-14 11:31:56 -07: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