utils

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 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 added in v0.2.3

type Option []Options

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

func (Option) Contains added in v0.2.3

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 added in v0.2.3

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 added in v0.2.3

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 added in v0.2.3

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

NewReadConfig returns new instance of ReadConfig.

func (*ReadConfig) Reader added in v0.2.3

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