spool

package
v0.0.0-...-7dfe24e Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-3.0, GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const PanicErrorCode = 8

Variables

View Source
var (
	Success                           = New(0, "succesful")
	Cancelled                         = New(0, "operation cancelled by user")
	NotFoundFailure                   = Cancelled.Next("target not found")
	FatalReadFailure                  = NotFoundFailure.Next("fatal failure during initialization")
	FatalWriteFailure                 = FatalReadFailure.Next("fatal failure during file write")
	WorkingDirectoryFailure           = FatalWriteFailure.Next("could not get current working directory")
	OpenRootFailure                   = WorkingDirectoryFailure.Next("failed to init root directory")
	RootFsFailure                     = OpenRootFailure.Next("failed to make fs from root")
	CacheReadFailure                  = RootFsFailure.Next("failed to read cache (from " + paths.ContextsFile.String())
	HydrationFailure                  = CacheReadFailure.Next("a hydrator failed")
	MenuFailure                       = HydrationFailure.Next("error during menu")
	NoTargetsFailure                  = MenuFailure.Next("no targets found")
	NoEditorFailure                   = NoTargetsFailure.Next("$EDITOR not set")
	NoDebugInfo                       = NoEditorFailure.Next("could not read debug info")
	ManFailure                        = New(120, "failure to generate manual pages")
	UnknownShellFailure               = New(110, "unable to detect shell type through $SHELL")
	CompletionAlreadyInstalledFailure = UnknownShellFailure.Next("completion seems already installed")
	CompletionFailure                 = CompletionAlreadyInstalledFailure.Next("failed to install completion")
	ProfilingFailure                  = CompletionFailure.Next("failed to initialize profiler")
)
View Source
var (
	Stderr   = os.Stderr
	Stdout   = os.Stdout
	StyleErr = style.New(func() lipgloss.Style {
		return lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Padding(0).Margin(0)
	})
	StyleWarn = style.New(func() lipgloss.Style {
		return lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Padding(0).Margin(0)
	})
)
View Source
var CodeMap = make(map[int]*ExitCode)
View Source
var Codes []ExitCode
View Source
var Panic = func(code *ExitCode, format string, values ...any) (any, error) {
	pkg := reflect.TypeOf(empty{}).PkgPath()
	v, err := fmt.Fprint(Stderr, StyleErr.Render(fmt.Sprintf(strings.TrimSpace(format), values...))+"\n")
	st := strings.Split(string(debug.Stack()), "\n")
	for i, l := range st {
		if strings.Contains(l, pkg) {
			st = st[i:]
			break
		}
	}

	_, _ = Warn("%s\n", strings.Join(st, "\n"))
	os.Exit(PanicErrorCode)
	return v, err
}
View Source
var Print = func(format string, values ...any) (any, error) {
	return fmt.Fprintf(Stdout, format, values...)
}
View Source
var Warn = func(format string, values ...any) (any, error) {
	return fmt.Fprint(Stderr, StyleWarn.Render(fmt.Sprintf(strings.TrimSpace(format), values...))+"\n")
}

Functions

This section is empty.

Types

type ExitCode

type ExitCode struct {
	Value   int
	Message string
}

func New

func New(num int, message string) *ExitCode

func (*ExitCode) Exit

func (e *ExitCode) Exit()

func (*ExitCode) Next

func (e *ExitCode) Next(message string) *ExitCode

Jump to

Keyboard shortcuts

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