common

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IsDebug set to `true` will disable debug asserts and other stuff.
	IsDebug = false

	// DebugLog set to `true` will turn on debug logging.
	DebugLog = false
)
View Source
const (
	GithooksEmoji = "🦎"

	// ListItemLiteral is the list item used for CLI and other printing stuff.
	ListItemLiteral = "•"
)
View Source
const (
	// DefaultFileModeDirectory is the default file mod for directory creation.
	DefaultFileModeDirectory = os.FileMode(0775) // nolint:gomnd

	// DefaultFileModeFile is the default file mod for file creation.
	DefaultFileModeFile = os.FileMode(0664) // nolint:gomnd

)
View Source
const WindowsExecutableSuffix = ".exe"

WindowsExecutableSuffix is the Windows executable suffix.

View Source
const WindowsOsName = "windows"

WindowsOsName is the Windows platform name.

Variables

This section is empty.

Functions

func All

func All(vs []interface{}, f func(interface{}) bool) bool

All returns `true` if all of the strings in the slice satisfy the predicate `f`.

func Any

func Any(vs []interface{}, f func(interface{}) bool) bool

Any returns `true` if one of the strings in the slice satisfies the predicate `f`.

func AssertNoErrorPanic

func AssertNoErrorPanic(err error, lines ...string)

AssertNoErrorPanic Assert no error, otherwise panic.

func AssertNoErrorPanicF

func AssertNoErrorPanicF(err error, format string, args ...interface{})

AssertNoErrorPanicF Assert no error, otherwise panic.

func AssertOrPanic

func AssertOrPanic(condition bool, lines ...string)

AssertOrPanic Assert a condition is `true`, otherwise panic.

func AssertOrPanicF

func AssertOrPanicF(condition bool, format string, args ...interface{})

AssertOrPanicF Assert a condition is `true`, otherwise panic.

func Chmod

func Chmod(filePath string, mode os.FileMode) error

Chmod is a wrapper around the basic Unix `chmod`. For windows its different.

func CombineErrors

func CombineErrors(err error, errs ...error) error

CombineErrors combines multiple errors into one.

func ContainsDotFile

func ContainsDotFile(p string) bool

ContainsDotFile checks if path `p` contains `.*` parts (dotfiles) in the path.

func CopyFileOrDirectory

func CopyFileOrDirectory(src string, dest string) error

CopyFileOrDirectory copies a directory or file from `src` to `dest` replacing `dest` if it exists. Copies also symlinks.

func CopyFileWithBackup

func CopyFileWithBackup(src string, dst string, backupDir string, doMoveInstead bool) (err error)

CopyFileWithBackup copies (if `!doMoveInstead`, otherwise moves) the contents of the file named `src` to the file named by `dst`. If `dst` already exists it will be force moved to `backupDir/dst`. Make sure that `backupDir` is on the same device as `dst` as otherwise this will fail! After this, any failure tries to recover as good as possible to not have touched/moved `dst`.

func DebugAssert

func DebugAssert(condition bool, lines ...string)

DebugAssert asserts that a condition is `true`, otherwise panic (disabled in production mode).

func DebugAssertF

func DebugAssertF(condition bool, format string, args ...interface{})

DebugAssertF asserts that a condition is `true`, otherwise panic (disabled in production mode).

func DebugAssertNoError

func DebugAssertNoError(err error, lines ...string)

DebugAssertNoError asserts that a condition is `true`, otherwise panic (disabled in production mode).

func DebugAssertNoErrorF

func DebugAssertNoErrorF(err error, format string, args ...interface{})

DebugAssertNoErrorF asserts that a condition is `true`, otherwise panic (disabled in production mode).

func Error

func Error(lines ...string) error

Error makes an error message.

func ErrorF

func ErrorF(format string, args ...interface{}) error

ErrorF makes an error message.

func ExtractTarGz

func ExtractTarGz(gzipStream io.Reader, baseDir string) (paths []string, err error)

ExtractTarGz extracts `.tar.gz` streams to `baseDir` which must not exist. Overwrites everything.

func ExtractZip

func ExtractZip(zipFile io.ReaderAt, zipFileSize int64, destDir string) (paths []string, err error)

ExtractZip will decompress a zip archive, moving all files and folders within the zip file in `src` to an output directory `dest`. Returns all file paths in the zip file.

func Filter

func Filter(vs []interface{}, f func(interface{}) bool) []interface{}

Filter returns a new slice containing all strings in the slice that satisfy the predicate `f`.

func FormatError

func FormatError(err error) string

FormatError formats an error.

func FormatMessage

func FormatMessage(suffix string, indent string, lines ...string) string

FormatMessage formats several lines with a suffix and indent.

func FormatMessageF

func FormatMessageF(suffix string, indent string, format string, args ...interface{}) string

FormatMessageF formats several lines with a suffix and indent.

func GetAllFiles

func GetAllFiles(root string) (files []string, err error)

GetAllFiles returns all the files in directory `root` (non-recursive).

func GetCombinedOutputFromExecutable

func GetCombinedOutputFromExecutable(
	ctx IExecContext,
	exe IExecutable,
	pipeSetup PipeSetupFunc,
	args ...string) ([]byte, error)

GetCombinedOutputFromExecutable calls an executable and returns its stdout and stderr output.

func GetCtty

func GetCtty() (*os.File, error)

GetCtty gets the file descriptor of the controlling terminal.

func GetDuration

func GetDuration(since time.Duration) time.Duration

GetDuration gets the duration since a time `since`.

func GetFiles

func GetFiles(root string, filter FileFilter) (files []string, err error)

GetFiles returns the filtered files in directory `root` (non-recursive). The nil Filter returns all files.

func GetOutputFromExecutable

func GetOutputFromExecutable(
	ctx IExecContext,
	exe IExecutable,
	pipeSetup PipeSetupFunc,
	args ...string) ([]byte, error)

GetOutputFromExecutable calls an executable and returns its stdout output.

func GetOutputFromExecutableSep

func GetOutputFromExecutableSep(
	ctx IExecContext,
	exe IExecutable,
	pipeSetup PipeSetupFunc,
	args ...string) ([]byte, []byte, error)

GetOutputFromExecutableSep calls an executable and gets stdout and stderr separate.

func GetOutputFromExecutableTrimmed

func GetOutputFromExecutableTrimmed(
	ctx IExecContext,
	exe IExecutable,
	pipeSetup func() (io.Reader, io.Writer, io.Writer),
	args ...string) (string, error)

GetOutputFromExecutableTrimmed calls an executable and returns its trimmed stdout output.

func GetProgressBar

func GetProgressBar(log ILogContext, title string, length int) (bar *pb.ProgressBar)

GetProgressBar returns a progressbar or nil (if log has no terminal attached).

func GetSHA1Hash

func GetSHA1Hash(reader io.Reader) (string, error)

GetSHA1Hash gets the SHA1 hash of a string.

func GetSHA1HashFile

func GetSHA1HashFile(path string) (sha string, err error)

GetSHA1HashFile gets the SHA1 hash of a file. It properly mimics `git hash-file`.

func GetSHA256Hash

func GetSHA256Hash(reader io.Reader) (string, error)

GetSHA256Hash gets the SHA1 hash of a string.

func GetStartTime

func GetStartTime() time.Duration

GetStartTime gets the start duration.

func GetTempPath

func GetTempPath(dir string, postfix string) (file string)

GetTempPath creates a random non-existing path with a postfix `postfix` in directory `dir` (can be empty to use the working dir).

func Glob

func Glob(pattern string, ignoreErrors bool) (l []string, err error)

Glob adds double-star support to the core path/filepath Glob function. It's useful when your globs might have double-stars, but you're not sure. On Windows `\\` or '/' will work as a path separator in pattern. Adpated for syntax escaping and only "/" paths in output. Package 'doublestar/v3' is awefully slow.

func GlobMatch

func GlobMatch(pattern string, path string) (bool, error)

GlobMatch matches a pattern against a path.

func HandleCLIErrors

func HandleCLIErrors(
	err interface{},
	cwd string,
	log ILogContext,
	getBugReportingInfo func(string) (string, error)) bool

HandleCLIErrors generally handles errors for the Githooks executables. Argument `cwd` can be empty.

func IsDirectory

func IsDirectory(path string) bool

IsDirectory checks if a path is a existing directory.

func IsExecutable

func IsExecutable(path string) bool

IsExecutable checks if the path is executable by the current user.

func IsFile

func IsFile(path string) bool

IsFile checks if a path is a existing file.

func IsPathError

func IsPathError(err error) bool

IsPathError returns `true` if the error is a `os.PathError`.

func IsPathExisting

func IsPathExisting(path string) (bool, error)

IsPathExisting checks if a path exists.

func IsWritable

func IsWritable(path string) bool

IsWritable checks if the path is writable by the current user.

func LoadJSON

func LoadJSON(file string, repr interface{}) error

LoadJSON loads and parses JSON file into a representation.

func LoadYAML

func LoadYAML(file string, repr interface{}) error

LoadYAML loads and parses JSON file into a representation.

func MakeExecutable

func MakeExecutable(path string) (err error)

MakeExecutable makes a file executable.

func MakeRelative

func MakeRelative(base string, path string) (s string, e error)

MakeRelative makes a `path` relative to `base`.

func Map

func Map(vs []interface{}, f func(interface{}) interface{}) []interface{}

Map returns a new slice containing the results of applying the function `f` to each string in the original slice.

func MatchLineRegexInFile

func MatchLineRegexInFile(filePath string, regex *regexp.Regexp) (found bool, err error)

MatchLineRegexInFile returns if the regex matches in the file `filePath`.

func Panic

func Panic(lines ...string)

Panic panics with an `error`.

func PanicF

func PanicF(format string, args ...interface{})

PanicF panics with an `error`.

func PanicIf

func PanicIf(condition bool, lines ...string)

PanicIf Assert a condition is `true`, otherwise panic.

func PanicIfF

func PanicIfF(condition bool, format string, args ...interface{})

PanicIfF Assert a condition is `true`, otherwise panic.

func ReadJSON

func ReadJSON(reader io.Reader, repr interface{}) error

ReadJSON reads the JSON representation of `repr` from `reader`.

func ReplaceTilde

func ReplaceTilde(p string) (string, error)

ReplaceTilde replaces a prefix tilde '~' character in a path with the home dir.

func ReplaceTildeWith

func ReplaceTildeWith(p string, repl string) string

ReplaceTildeWith replaces a prefix tilde '~' character in a path with the string `repl`.

func RunExecutable

func RunExecutable(
	ctx IExecContext,
	exe IExecutable,
	pipeSetup PipeSetupFunc,
	args ...string) error

RunExecutable calls an executable.

func SplitPath

func SplitPath(p string) []string

SplitPath splits a path `p` (only forward slashes) into each directory name.

func StoreJSON

func StoreJSON(file string, repr interface{}) error

StoreJSON stores a representation in a JSON file.

func StoreYAML

func StoreYAML(file string, repr interface{}) error

StoreYAML stores a representation in a JSON file.

func ToErrorWriter

func ToErrorWriter(log ILogContext) io.Writer

ToErrorWriter wrapps the log context error into a `io.Writer`.

func ToInfoWriter

func ToInfoWriter(log ILogContext) io.Writer

ToInfoWriter wrapps the log context info into a `io.Writer`.

func TouchFile

func TouchFile(filePath string, makeDirs bool) (err error)

TouchFile touches a file `path`.

func VerifyFile

func VerifyFile(file io.Reader, signature io.Reader, publicKey string) error

VerifyFile verifies an input `file` with its `signature` provided a public GPG kex in hex format.

func WalkFiles

func WalkFiles(root string, filter FileFunc) error

WalkFiles walks all files in directory `root` (non-recursive) and calls `filter`.

func WalkPaths

func WalkPaths(root string, filter FileFunc) error

WalkPaths walks all paths in directory `root` (recursive) and calls `filter`. Filter can return `filepath.SkipDir` which skips the current directory.

func WriteJSON

func WriteJSON(writer io.Writer, repr interface{}) error

WriteJSON writes the JSON representation of `repr` to `writer`.

Types

type CmdContext

type CmdContext struct {
	BaseCmd string
	Cwd     string
	Env     []string
}

CmdContext defines the command context to execute commands.

func (*CmdContext) Check

func (c *CmdContext) Check(args ...string) error

Check checks if a command executed successfully.

func (*CmdContext) CheckPiped

func (c *CmdContext) CheckPiped(args ...string) error

CheckPiped checks if a command executed successfully.

func (*CmdContext) Get

func (c *CmdContext) Get(args ...string) (string, error)

Get executes a command and gets the stdout.

func (*CmdContext) GetCombined

func (c *CmdContext) GetCombined(args ...string) (string, error)

GetCombined executes a command and gets the combined stdout and stderr.

func (*CmdContext) GetExitCode

func (c *CmdContext) GetExitCode(args ...string) (int, error)

GetExitCode get the exit code of the command.

func (*CmdContext) GetSplit

func (c *CmdContext) GetSplit(args ...string) ([]string, error)

GetSplit executes a command and splits the output by newlines.

type ExecContext

type ExecContext struct {
	Cwd string
	Env []string
}

ExecContext defines a context to execute commands.

func (*ExecContext) GetEnv

func (c *ExecContext) GetEnv() []string

GetEnv gets the environement variables.

func (*ExecContext) GetWorkingDir

func (c *ExecContext) GetWorkingDir() string

GetWorkingDir gets the working dir.

type Executable

type Executable struct {
	// The absolute path of the hook script/executable.
	Cmd string

	// Arguments to the hook script/executable.
	Args []string
}

Executable contains the data to a script/executable file.

func (*Executable) GetArgs

func (e *Executable) GetArgs(args ...string) []string

GetArgs gets all args.

func (*Executable) GetCommand

func (e *Executable) GetCommand() string

GetCommand gets the first command.

func (*Executable) GetString

func (e *Executable) GetString() string

GetArgs gets all args.

type FileFilter

type FileFilter = func(path string, info os.FileInfo) bool

FileFilter is the filter for `GetFiles`.

type FileFunc

type FileFunc = func(path string, info os.FileInfo) error

FileFunc is the filter for `GetFiles`.

type GithooksFailure

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

GithooksFailure is a normal hook failure.

func (*GithooksFailure) Error

func (e *GithooksFailure) Error() string

type IExecContext

type IExecContext interface {
	GetWorkingDir() string
	GetEnv() []string
}

IExecContext defines the context interface to execute commands.

type IExecutable

type IExecutable interface {
	GetCommand() string
	GetArgs(args ...string) []string

	GetString() string
}

IExecutable defines the interface for a general executable.

type ILogContext

type ILogContext interface {
	// Log functions
	Debug(lines ...string)
	DebugF(format string, args ...interface{})
	Info(lines ...string)
	InfoF(format string, args ...interface{})
	Warn(lines ...string)
	WarnF(format string, args ...interface{})
	Error(lines ...string)
	ErrorF(format string, args ...interface{})
	ErrorWithStacktrace(lines ...string)
	ErrorWithStacktraceF(format string, args ...interface{})
	Panic(lines ...string)
	PanicF(format string, args ...interface{})

	// Assert helper functions
	ErrorOrPanicF(isFatal bool, err error, format string, args ...interface{})
	AssertWarn(condition bool, lines ...string)
	AssertWarnF(condition bool, format string, args ...interface{})
	DebugIf(condition bool, lines ...string)
	DebugIfF(condition bool, format string, args ...interface{})
	InfoIf(condition bool, lines ...string)
	InfoIfF(condition bool, format string, args ...interface{})
	WarnIf(condition bool, lines ...string)
	WarnIfF(condition bool, format string, args ...interface{})
	ErrorIf(condition bool, lines ...string)
	ErrorIfF(condition bool, format string, args ...interface{})
	PanicIf(condition bool, lines ...string)
	PanicIfF(condition bool, format string, args ...interface{})
	AssertNoError(err error, lines ...string) bool
	AssertNoErrorF(err error, format string, args ...interface{}) bool
	AssertNoErrorPanic(err error, lines ...string)
	AssertNoErrorPanicF(err error, format string, args ...interface{})

	HasColors() bool
	ColorInfo(string) string
	ColorError(string) string
	ColorPrompt(string) string
	GetIndent() string

	GetInfoFormatter(withColor bool) func(format string, args ...interface{}) string
	GetErrorFormatter(withColor bool) func(format string, args ...interface{}) string
	GetPromptFormatter(withColor bool) func(format string, args ...interface{}) string

	GetInfoWriter() io.Writer
	IsInfoATerminal() bool

	GetErrorWriter() io.Writer
	IsErrorATerminal() bool
}

ILogContext defines the log interface.

type ILogStats

type ILogStats interface {
	ErrorCount() int
	WarningCount() int

	ResetStats()

	EnableStats()
	DisableStats()
}

ILogStats is an interface for log statistics.

type ITask

type ITask interface {
	Run(exitCh chan bool) (taskError error)
	Clone() ITask
}

ITask is a background task which can be run with `RunBackgroundTask`. The exit channel `exitCh` can be used to signal an early exit of the running task if it supports early termination.

func RunTaskWithProgress

func RunTaskWithProgress(
	taskIn ITask,
	log ILogContext,
	timeout time.Duration,
	sett ProgressSettings) (taskOut ITask, taskError error)

RunTaskWithProgress runs a task with a progress spinner (if available) in a coroutine. The returned task `taskOut` contains the output of the run. If the task timed out, it will be `nil`.

type LogContext

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

LogContext defines the data for a log context.

func CreateLogContext

func CreateLogContext(onlyStderr bool) (*LogContext, error)

CreateLogContext creates a log context.

func (*LogContext) AssertNoError

func (c *LogContext) AssertNoError(err error, lines ...string) bool

AssertNoError Assert no error, and otherwise log it.

func (*LogContext) AssertNoErrorF

func (c *LogContext) AssertNoErrorF(err error, format string, args ...interface{}) bool

AssertNoErrorF Assert no error, and otherwise log it.

func (*LogContext) AssertNoErrorPanic

func (c *LogContext) AssertNoErrorPanic(err error, lines ...string)

AssertNoErrorPanic asserts no error, and otherwise log and panic.

func (*LogContext) AssertNoErrorPanicF

func (c *LogContext) AssertNoErrorPanicF(err error, format string, args ...interface{})

AssertNoErrorPanicF asserts no error, and otherwise log and panic.

func (*LogContext) AssertWarn

func (c *LogContext) AssertWarn(condition bool, lines ...string)

AssertWarn Assert a condition is `true`, otherwise log.

func (*LogContext) AssertWarnF

func (c *LogContext) AssertWarnF(condition bool, format string, args ...interface{})

AssertWarnF Assert a condition is `true`, otherwise log.

func (*LogContext) ColorError

func (c *LogContext) ColorError(s string) string

ColorError returns the colorized string for error-like messages.

func (*LogContext) ColorInfo

func (c *LogContext) ColorInfo(s string) string

ColorInfo returns the colorized string for info-like messages.

func (*LogContext) ColorPrompt

func (c *LogContext) ColorPrompt(s string) string

ColorPrompt returns the colorized string for prompt-like messages.

func (*LogContext) Debug

func (c *LogContext) Debug(lines ...string)

Debug logs a debug message.

func (*LogContext) DebugF

func (c *LogContext) DebugF(format string, args ...interface{})

DebugF logs a debug message.

func (*LogContext) DebugIf

func (c *LogContext) DebugIf(condition bool, lines ...string)

DebugIf Assert a condition is `true`, otherwise log.

func (*LogContext) DebugIfF

func (c *LogContext) DebugIfF(condition bool, format string, args ...interface{})

DebugIfF Assert a condition is `true`, otherwise log.

func (*LogContext) DisableStats

func (c *LogContext) DisableStats()

DisableStats disables the log statistics.

func (*LogContext) EnableStats

func (c *LogContext) EnableStats()

EnableStats enables the log statistics.

func (*LogContext) Error

func (c *LogContext) Error(lines ...string)

Error logs an error.

func (*LogContext) ErrorCount

func (c *LogContext) ErrorCount() int

ErrorCount gets the number of logged errors.

func (*LogContext) ErrorF

func (c *LogContext) ErrorF(format string, args ...interface{})

ErrorF logs an error.

func (*LogContext) ErrorIf

func (c *LogContext) ErrorIf(condition bool, lines ...string)

ErrorIf Assert a condition is `true`, otherwise log.

func (*LogContext) ErrorIfF

func (c *LogContext) ErrorIfF(condition bool, format string, args ...interface{})

ErrorIfF Assert a condition is `true`, otherwise log.

func (*LogContext) ErrorOrPanicF

func (c *LogContext) ErrorOrPanicF(isFatal bool, err error, format string, args ...interface{})

ErrorOrPanicF logs an error or a fatal error and also with a potential occurred error.

func (*LogContext) ErrorWithStacktrace

func (c *LogContext) ErrorWithStacktrace(lines ...string)

ErrorWithStacktrace logs and error with the stack trace.

func (*LogContext) ErrorWithStacktraceF

func (c *LogContext) ErrorWithStacktraceF(format string, args ...interface{})

ErrorWithStacktraceF logs and error with the stack trace.

func (*LogContext) GetErrorFormatter

func (c *LogContext) GetErrorFormatter(withColor bool) func(format string, args ...interface{}) string

GetErrorFormatter formats an error.

func (*LogContext) GetErrorWriter

func (c *LogContext) GetErrorWriter() io.Writer

GetErrorWriter returns the error writer.

func (*LogContext) GetIndent

func (c *LogContext) GetIndent() string

GetIndent returns the used indent.

func (*LogContext) GetInfoFormatter

func (c *LogContext) GetInfoFormatter(withColor bool) func(format string, args ...interface{}) string

GetInfoFormatter formats an info.

func (*LogContext) GetInfoWriter

func (c *LogContext) GetInfoWriter() io.Writer

GetInfoWriter returns the info writer.

func (*LogContext) GetPromptFormatter

func (c *LogContext) GetPromptFormatter(withColor bool) func(format string, args ...interface{}) string

GetPromptFormatter formats a prompt.

func (*LogContext) HasColors

func (c *LogContext) HasColors() bool

HasColors returns if the log uses colors.

func (*LogContext) Info

func (c *LogContext) Info(lines ...string)

Info logs a info message.

func (*LogContext) InfoF

func (c *LogContext) InfoF(format string, args ...interface{})

InfoF logs a info message.

func (*LogContext) InfoIf

func (c *LogContext) InfoIf(condition bool, lines ...string)

InfoIf Assert a condition is `true`, otherwise log.

func (*LogContext) InfoIfF

func (c *LogContext) InfoIfF(condition bool, format string, args ...interface{})

InfoIfF Assert a condition is `true`, otherwise log.

func (*LogContext) IsErrorATerminal

func (c *LogContext) IsErrorATerminal() bool

IsErrorATerminal returns `true` if the error log is connected to a terminal.

func (*LogContext) IsInfoATerminal

func (c *LogContext) IsInfoATerminal() bool

IsInfoATerminal returns `true` if the info log is connected to a terminal.

func (*LogContext) Panic

func (c *LogContext) Panic(lines ...string)

Panic logs an error and calls panic with a GithooksFailure.

func (*LogContext) PanicF

func (c *LogContext) PanicF(format string, args ...interface{})

PanicF logs an error and calls panic with a GithooksFailure.

func (*LogContext) PanicIf

func (c *LogContext) PanicIf(condition bool, lines ...string)

PanicIf Assert a condition is `true`, otherwise log it.

func (*LogContext) PanicIfF

func (c *LogContext) PanicIfF(condition bool, format string, args ...interface{})

PanicIfF Assert a condition is `true`, otherwise log it.

func (*LogContext) ResetStats

func (c *LogContext) ResetStats()

ResetStats resets the log statistics.

func (*LogContext) Warn

func (c *LogContext) Warn(lines ...string)

Warn logs a warning message.

func (*LogContext) WarnF

func (c *LogContext) WarnF(format string, args ...interface{})

WarnF logs a warning message.

func (*LogContext) WarnIf

func (c *LogContext) WarnIf(condition bool, lines ...string)

WarnIf Assert a condition is `true`, otherwise log.

func (*LogContext) WarnIfF

func (c *LogContext) WarnIfF(condition bool, format string, args ...interface{})

WarnIfF Assert a condition is `true`, otherwise log.

func (*LogContext) WarningCount

func (c *LogContext) WarningCount() int

WarningCount gets the number of logged warnings.

type PipeSetupFunc

type PipeSetupFunc func() (io.Reader, io.Writer, io.Writer)

PipeSetupFunc is the setup function for the pipes executed by the below execution calls.

func UseOnlyStdin

func UseOnlyStdin(inPipe io.Reader) PipeSetupFunc

UseOnlyStdin returns a pipe setup function which pipes stdin.

func UseStdStreams

func UseStdStreams(pipeStdin bool, pipeStdOut bool, pipeStderr bool) PipeSetupFunc

UseStdStreams returns a pipe setup function which pipes to the standard in/out/err streams.

func UseStreams

func UseStreams(in io.Reader, out io.Writer, err io.Writer) PipeSetupFunc

UseStreams returns a pipe setup function which pipes everything.

type ProgressSettings

type ProgressSettings struct {
	Title             string
	TitleStillRunning string

	ProgressUpdateInterval    time.Duration
	ProgressStillRunningAfter time.Duration
}

ProgressSettings defines the settings for the progress spinner for `RunTaskWithProgress`.

func CreateDefaultProgressSettings

func CreateDefaultProgressSettings(title string, titleStillRunning string) ProgressSettings

CreateDefaultProgressSettings creates default progressbar settings.

Jump to

Keyboard shortcuts

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