io

package
v0.0.0-...-5566b07 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QUIET   = 1
	NORMAL  = 2
	VERBOSE = 4
	DEBUG   = 8
)

Variables

View Source
var Color = NewColorizer()

Functions

func AnswerToBool

func AnswerToBool(answer string) bool

func ColorStatus

func ColorStatus(on bool)

func Colorize

func Colorize(text string) string

func FileExists

func FileExists(path string) bool

func MappedStringOrDefault

func MappedStringOrDefault(data map[string]string, index, defaultValue string) string

func PrefixLines

func PrefixLines(lines []string, prefix string) []string

func PrefixLinesInString

func PrefixLinesInString(s, prefix string) string

func ReadFile

func ReadFile(path string) ([]byte, error)

func SplitLines

func SplitLines(s string) []string

func SubString

func SubString(input string, start int, length int) string

Types

type CollectedMessage

type CollectedMessage struct {
	Verbosity int
	Message   string
}

type CollectorIO

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

func NewCollectorIO

func NewCollectorIO(verbosity int, input Input) *CollectorIO

func (*CollectorIO) Argument

func (c *CollectorIO) Argument(name, defaultValue string) string

func (*CollectorIO) Arguments

func (c *CollectorIO) Arguments() map[string]string

func (*CollectorIO) Ask

func (c *CollectorIO) Ask(message, defaultValue string) string

func (*CollectorIO) HasCollectedMessages

func (c *CollectorIO) HasCollectedMessages() bool

func (*CollectorIO) HasCollectedMessagesForVerbosity

func (c *CollectorIO) HasCollectedMessagesForVerbosity(verbosity int) bool

func (*CollectorIO) Input

func (c *CollectorIO) Input() Input

func (*CollectorIO) IsDebug

func (c *CollectorIO) IsDebug() bool

func (*CollectorIO) IsInteractive

func (c *CollectorIO) IsInteractive() bool

func (*CollectorIO) IsQuiet

func (c *CollectorIO) IsQuiet() bool

func (*CollectorIO) IsVerbose

func (c *CollectorIO) IsVerbose() bool

func (*CollectorIO) Messages

func (c *CollectorIO) Messages() []*CollectedMessage

func (*CollectorIO) Option

func (c *CollectorIO) Option(name, defaultValue string) string

func (*CollectorIO) Options

func (c *CollectorIO) Options() map[string]string

func (*CollectorIO) StandardInput

func (c *CollectorIO) StandardInput() []string

func (*CollectorIO) Verbosity

func (c *CollectorIO) Verbosity() int

func (*CollectorIO) Write

func (c *CollectorIO) Write(message string, newline bool, verbosity int)

type Colorizer

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

Colorizer adds ascii color to a string

func NewColorizer

func NewColorizer() *Colorizer

NewColorizer creates a new Colorizer and checks if the current terminal supports colors Currently windows is just a hard disable

func (*Colorizer) Colorize

func (c *Colorizer) Colorize(text string) string

Colorize only adds color to a string if the terminal supports it

type DefaultIO

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

func NewDefaultIO

func NewDefaultIO(verbosity int, options map[string]string, arguments map[string]string) *DefaultIO

func (*DefaultIO) Argument

func (d *DefaultIO) Argument(name, defaultValue string) string

func (*DefaultIO) Arguments

func (d *DefaultIO) Arguments() map[string]string

func (*DefaultIO) Ask

func (d *DefaultIO) Ask(message string, defaultValue string) string

func (*DefaultIO) Input

func (d *DefaultIO) Input() Input

func (*DefaultIO) IsDebug

func (d *DefaultIO) IsDebug() bool

func (*DefaultIO) IsInteractive

func (d *DefaultIO) IsInteractive() bool

func (*DefaultIO) IsQuiet

func (d *DefaultIO) IsQuiet() bool

func (*DefaultIO) IsVerbose

func (d *DefaultIO) IsVerbose() bool

func (*DefaultIO) Option

func (d *DefaultIO) Option(name, defaultValue string) string

func (*DefaultIO) Options

func (d *DefaultIO) Options() map[string]string

func (*DefaultIO) StandardInput

func (d *DefaultIO) StandardInput() []string

func (*DefaultIO) Verbosity

func (d *DefaultIO) Verbosity() int

func (*DefaultIO) Write

func (d *DefaultIO) Write(message string, newline bool, verbosity int)

type IO

type IO interface {
	Verbosity() int
	Options() map[string]string
	Option(name, defaultValue string) string
	Arguments() map[string]string
	Argument(name, defaultValue string) string
	StandardInput() []string
	Input() Input
	IsInteractive() bool
	IsDebug() bool
	IsQuiet() bool
	IsVerbose() bool
	Write(message string, newline bool, verbosity int)
	Ask(message string, defaultValue string) string
}

type Input

type Input interface {
	Data() []string
	Option(name, defaultValue string) string
	Options() map[string]string
	Argument(name, defaultValue string) string
	Arguments() map[string]string
	Ask(message, defaultValue string) string
}

type StdIn

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

func NewStdIn

func NewStdIn(opts map[string]string, args map[string]string) *StdIn

func (*StdIn) Argument

func (s *StdIn) Argument(name, defaultValue string) string

func (*StdIn) Arguments

func (s *StdIn) Arguments() map[string]string

func (*StdIn) Ask

func (s *StdIn) Ask(message, defaultValue string) string

func (*StdIn) Data

func (s *StdIn) Data() []string

func (*StdIn) Option

func (s *StdIn) Option(name, defaultValue string) string

func (*StdIn) Options

func (s *StdIn) Options() map[string]string

Jump to

Keyboard shortcuts

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