ui

package
v2.5.8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ui contains some common UI elements, that use Survey library.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyOptionalInput = errors.New("empty input in optional field")

ErrEmptyOptionalInput is returned when an optional input is empty.

Functions

func Confirm

func Confirm(msg string, _ bool, opt ...Option) (bool, error)

func FileSelector

func FileSelector(msg, descr string, opt ...Option) (string, error)

func Input

func Input(msg, help string, validateFn func(s string) error) (string, error)

Input shows a text input field with a custom validator.

func NoValidation

func NoValidation(s string) error

func String

func String(msg, help string) (string, error)

String asks user to input string, accepts an empty input.

func StringRequire

func StringRequire(msg, help string) (string, error)

StringRequire requires user to input string.

func Time

func Time(msg string, _ ...Option) (time.Time, error)

Time asks the user to enter a date and time. For simplicity, the date and time are entered in two separate prompts. The date is optional, and if it is not given, the function terminates returning ErrEmptyOptionalInput. If the date is entered and is valid (checked with validators, you don't have to worry), the function will ask for time, which is then required.

func ValidateNotEmpty

func ValidateNotEmpty(s string) error

Types

type Option

type Option func(*inputOptions)

func WithDefaultFilename

func WithDefaultFilename(s string) Option

func WithHelp

func WithHelp(msg string) Option

WithHelp sets the help message.

func WithMustExist

func WithMustExist(b bool) Option

Directories

Path Synopsis
Package ask provides common functions for asking questions for getting user input on dump and export parameters.
Package ask provides common functions for asking questions for getting user input on dump and export parameters.

Jump to

Keyboard shortcuts

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