interfaces

package
v0.0.0-...-ed7c31d Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextStateUnknown = ContextState(iota)
	ContextStateUnstarted
	// all states that are > than `ContextStateStarted` are considered terminal,
	// so the order here is important
	ContextStateStarted
	ContextStateSucceeded
	ContextStateFailed
	ContextStateAborted
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveContext

type ActiveContext interface {
	context.Context

	Cause() error
	GetState() ContextState

	// TODO disambiguate between errors and exceptions
	// TODO rename this to Complete
	Cancel(error)

	// `After` runs a function after the context is complete (regardless of
	// any errors). `After`s are run in the reverse order of when they are
	// called,
	// like
	// defers but on a whole-program level.
	After(FuncActiveContext)

	// `Must` executes a function even if the context has been cancelled. If
	// the function returns an error, `Must` cancels the context. It is
	// meant for
	// defers that must be executed, like closing files, flushing buffers,
	// releasing locks.
	Must(FuncActiveContext)
}

type ActiveContextGetter

type ActiveContextGetter interface {
	GetActiveContext() ActiveContext
}

type Adder

type Adder[ELEMENT any] interface {
	Add(ELEMENT) error
}

type CLIFlagDefinitions

type CLIFlagDefinitions interface {
	BoolVar(variable *bool, name string, defaultValue bool, usage string)
	StringVar(variable *string, name string, defaultValue string, usage string)
	Var(value FlagValue, name string, usage string)
	Func(name, usage string, funk func(string) error)
	IntVar(variable *int, name string, defaultValue int, usage string)
}

TODO add completion options

type CLIFlagIOWrapper

type CLIFlagIOWrapper interface {
	FlagValue
	IOWrapper
}

type Coder

type Coder[OBJECT any, READER any, WRITER any] interface {
	DecoderFrom[OBJECT, READER]
	EncoderTo[OBJECT, WRITER]
}

type CoderBufferedReadWriter

type CoderBufferedReadWriter[OBJECT any] = Coder[OBJECT, *bufio.Reader, *bufio.Writer]

type CoderReadWriter

type CoderReadWriter[OBJECT any] = Coder[OBJECT, io.Reader, io.Writer]

type Collection

type Collection[ELEMENT any] interface {
	Lenner
	Iterable[ELEMENT]
}

type CollectionMutable

type CollectionMutable[ELEMENT any] interface {
	Collection[ELEMENT]
	Resetable
}

type CommandComponentWriter

type CommandComponentWriter interface {
	SetFlagDefinitions(CLIFlagDefinitions)
}

type Comparable

type Comparable[SELF any] interface {
	Lenner
	RuneDecoder
	Shift(int) SELF
}

type CompoundKeyer

type CompoundKeyer[T any] []StringKeyer[T]

func (CompoundKeyer[T]) GetKey

func (ck CompoundKeyer[T]) GetKey(e T) string

type ContainsKeyer

type ContainsKeyer interface {
	ContainsKey(string) bool
}

type ContextState

type ContextState uint8

func (ContextState) Error

func (state ContextState) Error() string

func (ContextState) Is

func (state ContextState) Is(target error) bool

func (ContextState) IsComplete

func (state ContextState) IsComplete() bool

func (ContextState) String

func (i ContextState) String() string

type DecoderFrom

type DecoderFrom[OBJECT any, READER any] interface {
	DecodeFrom(OBJECT, READER) (int64, error)
}

type DecoderFromBufferedReader

type DecoderFromBufferedReader[OBJECT any] = DecoderFrom[OBJECT, *bufio.Reader]

type DecoderFromReader

type DecoderFromReader[OBJECT any] = DecoderFrom[OBJECT, io.Reader]

type Delta

type Delta[ELEMENT any] interface {
	GetAdded() Set[ELEMENT]
	GetRemoved() Set[ELEMENT]
}

type DirectoryLayoutBaseEnvVar

type DirectoryLayoutBaseEnvVar interface {
	Stringer

	GetBaseEnvVarName() string
	GetBaseEnvVarValue() string

	MakePath(...string) DirectoryLayoutPath
}

type DirectoryLayoutPath

type DirectoryLayoutPath interface {
	Stringer

	GetBaseEnvVar() DirectoryLayoutBaseEnvVar
	GetTarget() string

	GetTemplate() string
}

type DirectoryLayoutXDG

type DirectoryLayoutXDG interface {
	GetDirHome() DirectoryLayoutBaseEnvVar
	GetDirCwd() DirectoryLayoutBaseEnvVar
	GetDirData() DirectoryLayoutBaseEnvVar
	GetDirConfig() DirectoryLayoutBaseEnvVar
	GetDirState() DirectoryLayoutBaseEnvVar
	GetDirCache() DirectoryLayoutBaseEnvVar
	GetDirRuntime() DirectoryLayoutBaseEnvVar

	CloneWithUtilityName(string) DirectoryLayoutXDG
}

type EncoderTo

type EncoderTo[OBJECT any, READER any] interface {
	EncodeTo(OBJECT, READER) (int64, error)
}

type EncoderToBufferedWriter

type EncoderToBufferedWriter[OBJECT any] = EncoderTo[OBJECT, *bufio.Writer]

type EncoderToWriter

type EncoderToWriter[OBJECT any] = EncoderTo[OBJECT, io.Writer]

type EnvVars

type EnvVars = map[string]string

type EnvVarsAdder

type EnvVarsAdder interface {
	AddToEnvVars(EnvVars)
}

type Equaler

type Equaler[ELEMENT any] interface {
	Equals(ELEMENT, ELEMENT) bool
}

TODO-P2 rename

type Equatable

type Equatable[ELEMENT any] interface {
	Equals(ELEMENT) bool
}

type ErrorHiddenWrapper

type ErrorHiddenWrapper interface {
	ErrorOneUnwrapper
	ShouldHideUnwrap() bool
}

When printing error trees, `error_coders` uses the presence of `ShouldHideUnwrap()` and its return value to determine if the parent error should be printed.

type ErrorManyUnwrapper

type ErrorManyUnwrapper interface {
	error
	Unwrap() []error
}

type ErrorOneUnwrapper

type ErrorOneUnwrapper interface {
	error
	Unwrap() error
}

type ErrorRetryable

type ErrorRetryable interface {
	error
	Recover(ActiveContext, FuncRetry, FuncRetryAborted)
}

type FlagValue

type FlagValue interface {
	StringerSetter
}

Value is the interface to the dynamic value stored in a flag. (The default value is represented as a string.)

If a Value has an IsBoolFlag() bool method returning true, the command-line parser makes -name equivalent to -name=true rather than using the next command-line argument.

Set is called once, in command line order, for each flag present. The flag package may call the [String] method with a zero-valued receiver, such as a nil pointer.

type FuncActiveContext

type FuncActiveContext = func(ActiveContext) error

type FuncIter

type FuncIter[ELEMENT any] func(ELEMENT) error

type FuncIterIO

type FuncIterIO[ELEMENT any] func(ELEMENT) (int64, error)

type FuncIterKey

type FuncIterKey func(string) error

type FuncIterWithKey

type FuncIterWithKey[ELEMENT any] func(string, ELEMENT) error

type FuncMakePrinter

type FuncMakePrinter[OUT any] func(WriterAndStringWriter) FuncIter[OUT]

type FuncRepool

type FuncRepool func()

type FuncRetry

type FuncRetry func()

type FuncRetryAborted

type FuncRetryAborted func(err error)

type FuncSetString

type FuncSetString func(string) error

type FuncString

type FuncString[T any] func(T) string

type FuncStringWriterFormat

type FuncStringWriterFormat[T any] func(WriterAndStringWriter, T) (int64, error)

type FuncTransform

type FuncTransform[ELEMENT any, T1 any] func(ELEMENT) (T1, error)

type FuncWriter

type FuncWriter func(io.Writer) (int64, error)

type FuncWriterElementInterface

type FuncWriterElementInterface[ELEMENT any] func(
	WriterAndStringWriter,
	ELEMENT,
) (int64, error)

type FuncWriterFormat

type FuncWriterFormat[T any] func(io.Writer, T) (int64, error)

type IOWrapper

type IOWrapper interface {
	ReadWrapper
	WriteWrapper
}

type Iterable

type Iterable[ELEMENT any] interface {
	All() Seq[ELEMENT]
}

type Keyer

type Keyer[ELEMENT any] interface {
	Key(ELEMENT) string
}

type Lenner

type Lenner interface {
	Len() int
}

type Lessor

type Lessor[ELEMENT any] interface {
	Less(ELEMENT, ELEMENT) bool
}

type LockSmith

type LockSmith interface {
	IsAcquired() bool
	Lock() error
	Unlock() error
}

type LockSmithGetter

type LockSmithGetter interface {
	GetLockSmith() LockSmith
}

type Pool

type Pool[T any] interface {
	GetWithRepool() (T, FuncRepool)
}

type PoolPtr

type PoolPtr[T any, TPtr Ptr[T]] interface {
	Pool[TPtr]
}

type Printer

type Printer interface {
	io.Writer

	GetFile() *os.File
	IsTty() bool

	// TODO add "isOn" function
	Caller(skip int) Printer
	Print(a ...any) (err error)
	PrintDebug(a ...any) (err error)
	Printf(f string, a ...any) (err error)
}

type Ptr

type Ptr[T any] interface {
	*T
}

type Pull

type Pull[ELEMENT any] = func() (ELEMENT, bool)

type Pull2

type Pull2[ELEMENT any, ELEMENT_TWO any] = func() (ELEMENT, ELEMENT_TWO, bool)

type ReadWrapper

type ReadWrapper interface {
	WrapReader(r io.Reader) (io.ReadCloser, error)
}

type Resetable

type Resetable interface {
	Reset()
}

type ResetablePtr

type ResetablePtr[ELEMENT any] interface {
	Ptr[ELEMENT]
	ResetWith(ELEMENT)
	Reset()
}

type ResetableWithError

type ResetableWithError interface {
	Reset() error
}

type Resetter

type Resetter[ELEMENT any] interface {
	Reset(ELEMENT)
	ResetWith(ELEMENT, ELEMENT)
}

type ResetterPtr

type ResetterPtr[
	ELEMENT any,
	ELEMENT_PTR Ptr[ELEMENT],
] interface {
	Reset(ELEMENT_PTR)
	ResetWith(ELEMENT_PTR, ELEMENT_PTR)
}

type RuneDecoder

type RuneDecoder interface {
	DecodeRune() (char rune, width int)
}

type Seq

type Seq[ELEMENT any] = iter.Seq[ELEMENT]

type Seq2

type Seq2[ELEMENT any, ELEMENT_TWO any] = iter.Seq2[ELEMENT, ELEMENT_TWO]

type SeqError

type SeqError[ELEMENT any] = iter.Seq2[ELEMENT, error]

type Set

type Set[ELEMENT any] interface {
	ContainsKeyer
	Iterable[ELEMENT]
	Keyer[ELEMENT]
	Lenner
	SetGetter[ELEMENT]
}

type SetGetter

type SetGetter[ELEMENT any] interface {
	Get(string) (ELEMENT, bool)
}

type SetMutable

type SetMutable[ELEMENT any] interface {
	Set[ELEMENT]
	Adder[ELEMENT]
	DelKey(string) error
	Resetable
}

type Setter

type Setter interface {
	Set(string) error
}

type SetterPtr

type SetterPtr[T any] interface {
	Ptr[T]
	Setter
}

type StringCoder

type StringCoder[T any] interface {
	DecoderFromReader[T]
	StringEncoderTo[T]
}

type StringEncoderTo

type StringEncoderTo[T any] interface {
	EncodeStringTo(T, WriterAndStringWriter) (int64, error)
}

type StringKeyer

type StringKeyer[T any] interface {
	GetKey(T) string
}

type StringKeyerPtr

type StringKeyerPtr[T any, TPtr Ptr[T]] interface {
	StringKeyer[T]
	GetKeyPtr(TPtr) string
}

type StringSetterPtr

type StringSetterPtr[T any] interface {
	Stringer
	Ptr[T]
	Setter
}

type Stringer

type Stringer interface {
	String() string
}

type StringerPtr

type StringerPtr[T any] interface {
	Stringer
	Ptr[T]
}

type StringerSetter

type StringerSetter interface {
	Stringer
	Setter
}

type StringerSetterPtr

type StringerSetterPtr[T any] interface {
	Stringer
	Setter
	Ptr[T]
}

type StringerWithHeadAndTail

type StringerWithHeadAndTail interface {
	Stringer
	GetHead() string
	GetTail() string
}

type Tridex

type Tridex interface {
	Collection[string]
	ContainsAbbreviation(string) bool
	ContainsExpansion(string) bool
	Abbreviate(string) string
	Expand(string) string
}

type TridexMutable

type TridexMutable interface {
	Tridex
	Add(string)
	Remove(string)
}

type Value

type Value interface {
	Stringer
	IsEmpty() bool
}

type ValuePtr

type ValuePtr[SELF Value] interface {
	Resetable
	ResetablePtr[SELF]
	StringerSetterPtr[SELF]
}

type WriteWrapper

type WriteWrapper interface {
	WrapWriter(w io.Writer) (io.WriteCloser, error)
}

type WriterAndStringWriter

type WriterAndStringWriter interface {
	io.Writer
	io.StringWriter
}

Source Files

  • coder.go
  • collections.go
  • command.go
  • context.go
  • contextstate_string.go
  • directory.go
  • elements.go
  • errors.go
  • io.go
  • iter.go
  • keyers.go
  • lock.go
  • main.go
  • pools.go
  • printer.go
  • string.go
  • value.go

Jump to

Keyboard shortcuts

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