ask

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCancelled   = errors.New("the question was cancelled")
	ErrUnavailable = errors.New("there is nobody to ask")
)
View Source
var ErrDenied = errors.New("the request was denied")

Functions

func Confirm

func Confirm(ctx context.Context, broker *Broker, confirmation Confirmation) error

func ConfirmWithin added in v0.11.0

func ConfirmWithin(
	ctx context.Context,
	broker *Broker,
	confirmation Confirmation,
	lapseAfter time.Duration,
) error

Types

type Broker

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

func New

func New() *Broker

func (*Broker) Ask

func (self *Broker) Ask(ctx context.Context, question Question) (int, error)

func (*Broker) AskWithin added in v0.11.0

func (self *Broker) AskWithin(
	ctx context.Context,
	question Question,
	lapseAfter time.Duration,
) (int, error)

func (*Broker) Changes

func (self *Broker) Changes() <-chan struct{}

func (*Broker) Current

func (self *Broker) Current() *Request

func (*Broker) Open

func (self *Broker) Open() func()

type Choice

type Choice struct {
	Label  string
	Detail string
	Labels []string
}

func (Choice) Question

func (self Choice) Question() Question

type Confirmation

type Confirmation struct {
	Label    string
	Intent   string
	Detail   string
	Language string
	Fields   []Field
}

func (Confirmation) Question

func (self Confirmation) Question() Question

type Field added in v0.11.0

type Field struct {
	Name      string
	Value     string
	IsSubject bool
}

type Option

type Option struct {
	Key   rune
	Label string
}

type Question

type Question struct {
	Label    string
	Intent   string
	Lapse    string
	Detail   string
	Language string
	Fields   []Field
	Options  []Option
	Default  int
}

func (Question) DefaultIndex

func (self Question) DefaultIndex() int

func (Question) IndexForKey

func (self Question) IndexForKey(key rune) int

type Request

type Request struct {
	Question Question
	// contains filtered or unexported fields
}

func (*Request) Cancel

func (self *Request) Cancel()

func (*Request) Choose

func (self *Request) Choose(index int)

func (*Request) Deadline

func (self *Request) Deadline() (time.Time, bool)

Jump to

Keyboard shortcuts

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