util

package
v0.4.0-beta.47 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const StartOfLine = -999

Variables

View Source
var VariableDetection = regexp.MustCompile(`(?i)\$([a-z0-9_]+)|\${([a-z0-9_]+)(([^a-z0-9_]+)(.*?))?}`)

Functions

func CaptureStdout

func CaptureStdout(f func()) string

func CollapseReturns

func CollapseReturns(input string) string

func Debugf

func Debugf(s string, i ...interface{})

func DecodeCursor

func DecodeCursor(cursor string) (lineDelta, columnDelta int)

func DumpNode

func DumpNode(node ast.Node, source []byte) string

func FileExists

func FileExists(name string) bool

func FindFile

func FindFile(files []string) string

Finds a file in the current directory or parents. Files are checked in the order they're provided.

func GetConsoleWidth

func GetConsoleWidth() int

func InspectList

func InspectList(l []string) string

func InspectString

func InspectString(s string) string

func IntMin

func IntMin(a, b int) int

func MakeRelative

func MakeRelative(filename string) string

func NodeLines

func NodeLines(v ast.Node, source []byte) string

func RandomString

func RandomString() string

func ReadAndFormatOutput

func ReadAndFormatOutput(reader io.Reader, indent int, prefix string, progressIndicator ProgressIndicator, out *bufio.Writer, logger *log.Logger, initialHeading string) bool

func RedirectLogger

func RedirectLogger(w io.Writer)

func RemoveColors

func RemoveColors(input string) string

func SetLoggerLevel

func SetLoggerLevel(level string)

func SubEnv

func SubEnv(environment map[string]string, source string) string

Performs environment substitution on the source string. Supports $VAR, or ${VAR} optionally with the -, :-, +, :+ modifiers. Ignores other (or invalid) modifiers, substituting as if they weren't there.

Types

type DummySpinner

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

func NewDummySpinner

func NewDummySpinner() *DummySpinner

func (*DummySpinner) Active

func (s *DummySpinner) Active() bool

func (*DummySpinner) CurrentHeading

func (s *DummySpinner) CurrentHeading() string

func (*DummySpinner) Error

func (s *DummySpinner) Error(message string)

func (*DummySpinner) HideAndExecute

func (s *DummySpinner) HideAndExecute(f func())

func (*DummySpinner) NewStep

func (s *DummySpinner) NewStep(message string)

func (*DummySpinner) SetMessage

func (s *DummySpinner) SetMessage(message string)

func (*DummySpinner) Skip

func (s *DummySpinner) Skip(message string)

func (*DummySpinner) Spin

func (s *DummySpinner) Spin()

func (*DummySpinner) Start

func (s *DummySpinner) Start()

func (*DummySpinner) Stop

func (s *DummySpinner) Stop()

func (*DummySpinner) Success

func (s *DummySpinner) Success(message string)

type Line

type Line struct {
	LastColumn        int
	FormattingStash   string
	CurrentlyIndented bool
	Dirty             bool
}

func (*Line) MoveCursor

func (l *Line) MoveCursor(col int)

type ProgressIndicator

type ProgressIndicator interface {
	Start()
	Stop()
	Active() bool
	CurrentHeading() string
}

type TokenResult

type TokenResult int
const (
	TokenCursor TokenResult = iota + 1
	TokenColour
	TokenWhitespace
	TokenDisplayStream
	TokenEmpty
)

func NextToken

func NextToken(input string) (token TokenResult, data string, rest string)

type WordWrapWriter

type WordWrapWriter struct {
	io.Writer
	AfterWrap      func(writer io.Writer) int
	CurrentLinePos int
	Columns        int
	// contains filtered or unexported fields
}

func NewWordWrapWriter

func NewWordWrapWriter(out io.Writer, columns int) *WordWrapWriter

func (*WordWrapWriter) Reset

func (w *WordWrapWriter) Reset()

func (*WordWrapWriter) SetAfterWrap

func (w *WordWrapWriter) SetAfterWrap(wrapper func(writer io.Writer) int)

func (*WordWrapWriter) Write

func (w *WordWrapWriter) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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