util

package
v0.4.0-beta.30 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const StartOfLine = -999

Variables

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

Replaces appearances of environment variables in source with variables present in the given environment. Replaces from longest environment variable name first.

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