tools

package
v0.0.0-...-05fba6c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log = zlog.Logger
)
View Source
var Trace = func(label string, msg string, vals ...interface{}) {}

Functions

func BashExec

func BashExec(cmd string) error

func CloseFile

func CloseFile(fp *os.File)

func CreateTempFile

func CreateTempFile(dir, pattern string) (string, error)

func EnsureDir

func EnsureDir(dirname string) error

func FmtTime

func FmtTime(t *time.Time) string

func FormatTime

func FormatTime(t *time.Time) string

func GetTermWindowSize

func GetTermWindowSize() (int, int, error)

GetTermWindowSize returns the terminal window size in rows, columns

func IsTermEnabled

func IsTermEnabled(fd int) bool

IsTermEnabled returns true if the given file descriptor is a terminal.

func LogStdError

func LogStdError(format string, v ...interface{})

func LogStderr

func LogStderr(err error, format string, v ...interface{})

func LogStderrExit

func LogStderrExit(err error, format string, v ...interface{})

func LogStdout

func LogStdout(format string, v ...interface{})

func MyPathTo

func MyPathTo(filename string) string

func OpenFile

func OpenFile(filename string, flag int) (*os.File, error)

os.O_RDWR|os.O_CREATE

func OpenLogger

func OpenLogger(verbose bool) (io.Closer, error)

OpenLogger opens the default rolling file logger and sets the verbosity of the logger

func OptsBool

func OptsBool(opts docopt.Opts, key string) bool

func OptsContains

func OptsContains(opts docopt.Opts, key string) bool

func OptsInt

func OptsInt(opts docopt.Opts, key string) int

func OptsSeconds

func OptsSeconds(opts docopt.Opts, key string) time.Duration

func OptsStr

func OptsStr(opts docopt.Opts, key string) string

func OptsStrSlice

func OptsStrSlice(opts docopt.Opts, key string) []string

func RandAlphaNumericStr

func RandAlphaNumericStr(n int) string

func RemoveNewLines

func RemoveNewLines(s string, r string) string

func StatExists

func StatExists(fileOrDirname string) (bool, error)

func TimeTrack

func TimeTrack(start time.Time, name string)

func TrimLength

func TrimLength(s string, maxLen int) string

Types

type BufferedWriteCloser

type BufferedWriteCloser struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func NewBufferedWriteCloser

func NewBufferedWriteCloser(writer io.Writer) *BufferedWriteCloser

This WriteCloser is guaranteed to never let a Write block. However, it's at the expense of more memory usage (especially if the writer passed in is slow).

func (*BufferedWriteCloser) Close

func (bw *BufferedWriteCloser) Close() error

func (*BufferedWriteCloser) Write

func (bw *BufferedWriteCloser) Write(data []byte) (n int, err error)

type BytesWriter

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

func NewBytesWriter

func NewBytesWriter() *BytesWriter

func (*BytesWriter) GetBytes

func (b *BytesWriter) GetBytes() []byte

func (*BytesWriter) GetString

func (b *BytesWriter) GetString() string

func (*BytesWriter) Write

func (b *BytesWriter) Write(p []byte) (int, error)

type LinenumWriter

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

func NewLinenumWriter

func NewLinenumWriter(start, cursorLine, prefixWidth int, cursor string) *LinenumWriter

func (*LinenumWriter) Close

func (lw *LinenumWriter) Close() error

func (*LinenumWriter) String

func (lw *LinenumWriter) String() string

func (*LinenumWriter) Write

func (lw *LinenumWriter) Write(data []byte) (n int, err error)

type MarshalledDuration

type MarshalledDuration struct {
	time.Duration
}

MarshalledDuration allows the duration to de-serialized from Yaml ToDo: json and Marshall Yaml

func (MarshalledDuration) GetDuration

func (t MarshalledDuration) GetDuration() time.Duration

func (MarshalledDuration) MarshalYAML

func (t MarshalledDuration) MarshalYAML() (interface{}, error)

func (*MarshalledDuration) UnmarshalYAML

func (t *MarshalledDuration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshalls Yaml to duration See: https://pkg.go.dev/gopkg.in/yaml.v2#Unmarshaler

type Runner

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

func NewRunner

func NewRunner(ctx RunnerContext) *Runner

func (*Runner) Execute

func (r *Runner) Execute(cmd string)

type RunnerContext

type RunnerContext interface {
	NewRootCmd() *cobra.Command
	HistoryAppend(string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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