prompt

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option []Options

Option implements method that helps in identifying if input is present in predefined list.

func (Option) Contains

func (inputOptions Option) Contains(input string) (bool, Options)

Contains checks if user passed input is part of predefined Options. If yes returns 'true' else returns 'false'.

type Options

type Options struct {
	Name  string `json:"name,omitempty" yaml:"name,omitempty"`
	Short string `json:"short,omitempty" yaml:"short,omitempty"`
}

Options that should be considered while configuring the shell reader. ex: yes/no (name) (y/n) (short) To get about value the options would look like: []Options{{Name: yes,Short: y}, {Name: no,Short: n}}.

type ReadConfig

type ReadConfig struct {
	ShellName    string    `json:"shell_name,omitempty" yaml:"shell_name,omitempty"`
	ShellMessage string    `json:"shell_message,omitempty" yaml:"shell_message,omitempty"`
	InputOptions []Options `json:"inputs,omitempty" yaml:"inputs,omitempty"`
	// contains filtered or unexported fields
}

ReadConfig holds the necessary inputs that is required by Reader.

func NewReadConfig

func NewReadConfig(name, message string, options []Options, logger *logrus.Logger) *ReadConfig

NewReadConfig returns new instance of ReadConfig.

func (*ReadConfig) Reader

func (cfg *ReadConfig) Reader() (bool, Options)

Reader reads the inputs from the shell input and matches against the inputs set. This would help one in designing the CLI commands that interactively takes input from end user ang validate them. For example: taking inputs such as yes or no from end user.

Jump to

Keyboard shortcuts

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