shared

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDirectory

func CheckDirectory(path string) error

CheckDirectory checks if a directory exists otherwise returns an error

func CheckDirectoryOrCreate

func CheckDirectoryOrCreate(path string) error

func CheckEmptyDirectoryOrCreate

func CheckEmptyDirectoryOrCreate(path string) error

func CopyDirectory

func CopyDirectory(src, dst string) error

CopyDirectory recursively copies a directory

func CopyFile

func CopyFile(from string, to string) error

func CopyFileWithReplacement

func CopyFileWithReplacement(from string, to string, replacements []Replacement) error

func CreateDirIf

func CreateDirIf(path string) error

func Debug

func Debug() bool

func Exit

func Exit(msg string, args ...any)

func ExitOnError

func ExitOnError(err error, msg string, args ...any)

func FileExists

func FileExists(p string) bool

func ForwardLogs

func ForwardLogs(r io.ReadCloser, w io.Writer)

func GenerateTree

func GenerateTree(p, indent string) (string, error)

GenerateTree recursively generates a string representation of the directory tree

func HandleError

func HandleError(err error)

func IsOutputError

func IsOutputError(err error) (error, bool)

func IsUserError

func IsUserError(err error) bool

func IsUserWarning

func IsUserWarning(err error) bool

func NewOutputError

func NewOutputError(format string, args ...any) error

func NewUserWarning

func NewUserWarning(format string, args ...any) error

func ParseError

func ParseError(s string) error

func SetDebug

func SetDebug(d bool)

func SetTodo

func SetTodo(t bool)

func SetTrace

func SetTrace(t bool)

func Todo

func Todo() bool

func Trace

func Trace() bool

func UnexpectedExitOnError

func UnexpectedExitOnError(err error, msg string, args ...any)

func UserErrorMessage

func UserErrorMessage(err error) string

func UserWarnMessage

func UserWarnMessage(err error) string

func WrapStart

func WrapStart(cmd *exec.Cmd, logger BaseLogger) error

func Wrapf

func Wrapf(err error, format string, args ...any) error

Types

type BaseLogger

type BaseLogger interface {
	Write(p []byte) (n int, err error)

	SetLevel(lvl LogLevel)

	Info(format string, args ...any)

	Tracef(format string, args ...any)
	Debugf(format string, args ...any)
	DebugMe(format string, args ...any)
	TODO(format string, args ...any)

	Wrapf(err error, format string, args ...any) error
	Errorf(format string, args ...any) error
}

BaseLogger is the Minimum logger interface

type CopyInstruction

type CopyInstruction struct {
	Name string
	Path string
}

type Dir

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

func Local

func Local(dir string) (*Dir, error)

func MustLocal

func MustLocal(dir string) Dir

func NewDir

func NewDir(dir string) Dir

func (*Dir) Absolute

func (d *Dir) Absolute() string

func (*Dir) Join

func (d *Dir) Join(other Dir) Dir

func (*Dir) Relative

func (d *Dir) Relative() string

func (*Dir) RelativeFrom

func (d *Dir) RelativeFrom(base Dir) (*Dir, error)

type File

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

func NewFile

func NewFile(file string) File

func (*File) Base

func (f *File) Base() string

func (*File) Relative

func (f *File) Relative() string

func (*File) RelativeFrom

func (f *File) RelativeFrom(base Dir) (*File, error)

func (*File) RelativePath

func (f *File) RelativePath() string

type LogLevel

type LogLevel = string
const (
	TraceLevel LogLevel = "trace"
	DebugLevel LogLevel = "debug"
)

type Logger

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

func NewLogger

func NewLogger(action string, args ...any) *Logger

func (*Logger) Catch

func (l *Logger) Catch()

func (*Logger) DebugMe

func (l *Logger) DebugMe(format string, args ...any)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any) error

func (*Logger) IfNot

func (l *Logger) IfNot(base BaseLogger) BaseLogger

func (*Logger) Info

func (l *Logger) Info(format string, args ...any)

func (*Logger) Message

func (l *Logger) Message(format string, args ...any)

func (*Logger) Oops

func (l *Logger) Oops(format string, args ...any)

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl LogLevel)

func (*Logger) TODO

func (l *Logger) TODO(format string, args ...any)

func (*Logger) Tracef

func (l *Logger) Tracef(format string, args ...any)

func (*Logger) UserFatal

func (l *Logger) UserFatal(err error)

func (*Logger) UserFatalMessage

func (l *Logger) UserFatalMessage(err error) string

func (*Logger) Warn

func (l *Logger) Warn(err error)

func (*Logger) WarnUnique added in v0.0.9

func (l *Logger) WarnUnique(err error)

func (*Logger) Wrapf

func (l *Logger) Wrapf(err error, format string, args ...any) error

func (*Logger) Write

func (l *Logger) Write(p []byte) (n int, err error)

type OutputError

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

func (*OutputError) Error

func (u *OutputError) Error() string

type Replacement

type Replacement struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
}

type Runner

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

func NewRunner

func NewRunner(bin string, dir Dir, args []string, out BaseLogger, override BaseLogger) *Runner

func (*Runner) Run

func (r *Runner) Run() error

type UserError

type UserError struct {
	Value      string
	Suggestion string
}

func NewUserError

func NewUserError(format string, args ...any) *UserError

func (*UserError) Error

func (u *UserError) Error() string

func (*UserError) WithSuggestion

func (u *UserError) WithSuggestion(s string) *UserError

type UserWarning

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

func (*UserWarning) Error

func (u *UserWarning) Error() string

Jump to

Keyboard shortcuts

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