shared

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 20 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Agent   = ContextLoggerKey("agent")
	Service = ContextLoggerKey("service")
)

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 Confirm added in v0.0.21

func Confirm(s string) bool

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 DirectoryExists added in v0.0.13

func DirectoryExists(p string) bool

func Exit

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

func ExitOnError

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

func ExitOnFalse added in v0.0.16

func ExitOnFalse(b bool, 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 MultiErrors added in v0.0.13

func MultiErrors(errs ...error) error

func NewOutputError

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

func NewUserWarning

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

func Override added in v0.0.13

func Override() bool

func ParseError

func ParseError(s string) error

func RequireExec added in v0.0.15

func RequireExec(bins ...string) ([]string, bool)

func SetDebug

func SetDebug(d bool)

func SetOverride added in v0.0.13

func SetOverride(o 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

func AgentLogger added in v0.0.31

func AgentLogger(ctx context.Context) BaseLogger

type ConfirmModel added in v0.0.21

type ConfirmModel struct {
	Prompt string
	// contains filtered or unexported fields
}

func (ConfirmModel) Init added in v0.0.21

func (m ConfirmModel) Init() tea.Cmd

func (ConfirmModel) Update added in v0.0.21

func (m ConfirmModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (ConfirmModel) View added in v0.0.21

func (m ConfirmModel) View() string

type ContextLoggerKey added in v0.0.13

type ContextLoggerKey string

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, args ...any) 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 DirReader added in v0.0.13

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

func NewDirReader added in v0.0.13

func NewDirReader() *DirReader

func (*DirReader) AbsoluteDir added in v0.0.13

func (dr *DirReader) AbsoluteDir(dir Dir) string

func (*DirReader) AbsoluteFile added in v0.0.13

func (dr *DirReader) AbsoluteFile(f File) string

func (*DirReader) At added in v0.0.13

func (dr *DirReader) At(root string) *DirReader

func (*DirReader) ReadDir added in v0.0.13

func (dr *DirReader) ReadDir(dir Dir) ([]os.DirEntry, error)

func (*DirReader) ReadFile added in v0.0.13

func (dr *DirReader) ReadFile(f File) ([]byte, error)

type FSReader added in v0.0.13

type FSReader struct {
	FS fs.FS
	// contains filtered or unexported fields
}

func Embed added in v0.0.13

func Embed(fsys fs.FS) *FSReader

func (*FSReader) Absolute added in v0.0.13

func (fr *FSReader) Absolute(dir Dir) string

func (*FSReader) AbsoluteDir added in v0.0.13

func (fr *FSReader) AbsoluteDir(dir Dir) string

func (*FSReader) AbsoluteFile added in v0.0.13

func (fr *FSReader) AbsoluteFile(f File) string

func (*FSReader) At added in v0.0.13

func (fr *FSReader) At(root string) *FSReader

func (*FSReader) Copy added in v0.0.13

func (fr *FSReader) Copy(s string, file string) error

func (*FSReader) ReadDir added in v0.0.13

func (fr *FSReader) ReadDir(dir Dir) ([]os.DirEntry, error)

func (*FSReader) ReadFile added in v0.0.13

func (fr *FSReader) ReadFile(f File) ([]byte, 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 FileSystem added in v0.0.13

type FileSystem interface {
	AbsoluteFile(f File) string
	AbsoluteDir(dir Dir) string
	ReadDir(dir Dir) ([]os.DirEntry, error)
	ReadFile(file File) ([]byte, error)
}

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 S added in v0.0.13

type S = string

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