prompt

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package prompt 简单的终端交互界面

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prompt

type Prompt struct {
	// contains filtered or unexported fields
}

Prompt 终端交互对象

func New

func New(delim byte, input io.Reader, output io.Writer, defaultColor colors.Color) *Prompt

New 声明 Prompt 变量

delim 从 input 读取内容时的分隔符,如果为空,则采用 \n; defaultColor 默认值的颜色,如果该值无效,则会 panic。

func (*Prompt) Bool

func (p *Prompt) Bool(q string, def bool) (bool, error)

Bool 输出 bool 问题,并获取用户的回答内容

func (*Prompt) Map

func (p *Prompt) Map(q string, maps map[string]string, def ...string) (selected []string, err error)

Map 输出一个单选问题,并获取用户的选择项

q 表示问题内容; maps 表示可选的问题列表; def 表示默认项的索引,必须在 maps 之内。

func (*Prompt) Slice

func (p *Prompt) Slice(q string, slice []string, def ...int) (selected []int, err error)

Slice 输出一个选择性问题,并获取用户的选择项

q 表示问题内容; slice 表示可选的问题列表; def 表示默认项的索引,必须在 slice 之内。

func (*Prompt) String

func (p *Prompt) String(q, def string) (string, error)

String 输出问题,并获取用户的回答内容

q 显示的问题内容; def 表示默认值。

Jump to

Keyboard shortcuts

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