ui

package
v0.0.0-...-cb3607a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

ui is a simple abstraction for implementing easily scriptable user interfaces in cli/tui enviroments.

implements github.com/lordrusk/dctl/menu

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Hf HandlerFunc

	Flags    []string // used for menu
	UseMenu  bool
	PassFlag string
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(r io.Reader, sf bufio.SplitFunc, flags []string, passFlag string, useMenu bool) *Handler

passFlag is the flag passed to menu to turn on password input. Can be empty string

func (*Handler) Ask

func (h *Handler) Ask(m Menu) (interface{}, interface{}, error)

menu must be implemented in HandlerFunc

for cleaner code

func (*Handler) NextBytes

func (h *Handler) NextBytes(prompt string) ([]byte, error)

get the next input as a []byte

func (*Handler) NextInt

func (h *Handler) NextInt(prompt string) (int, error)

get the next input as a int

func (*Handler) NextString

func (h *Handler) NextString(prompt string) (string, error)

get the next input as a string

func (*Handler) PassInput

func (h *Handler) PassInput(prompt string) ([]byte, error)

basic function to get user input allows for password input

type HandlerFunc

type HandlerFunc func(Menu) (interface{}, interface{}, error)

A handler function.

return's selected key and value from Menu

type Menu map[interface{}]interface{}

Jump to

Keyboard shortcuts

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