entry

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package entry dispatches fast-path entry points before any heavy initialization runs, and records time to first paint.

A warm Rex overlay, a Go process and a bubbletea first frame cost about 85ms before any application work. Everything a fast path does before its first paint adds to that floor, so main calls Dispatch before touching discovery, git, watchers or config, and defers that work until MarkPainted.

if code, ok := router.Dispatch(os.Args[1:]); ok {
	os.Exit(code)
}

Index

Constants

View Source
const EnvTTFP = "REXUIKIT_TTFP"

EnvTTFP names a file that receives one line per run: entry=<name> ttfp_ms=<n>.

Variables

This section is empty.

Functions

func Deferred

func Deferred(fn func())

Deferred runs fn once after the first MarkPainted. A process that exits before paint drops it without waiting.

func MarkPainted

func MarkPainted()

MarkPainted reports the first non-empty frame. Call it once after the first render; later calls are no-ops.

func Painted

func Painted() <-chan struct{}

Painted returns a channel that the first MarkPainted closes. A bubbletea program wraps it in a tea.Cmd, which keeps bubbletea out of this package.

Types

type Func

type Func func(ctx context.Context, args []string) int

Func is a fast-path boot function. Its return value is the exit status.

type Router

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

Router maps entry names to boot functions. The zero value is ready to use.

func (*Router) Dispatch

func (r *Router) Dispatch(args []string) (code int, matched bool)

Dispatch runs the entry named by args[0] with args[1:], where args is os.Args[1:]. With no matching entry it returns matched=false and runs nothing, so the caller continues into its normal main.

func (*Router) Handle

func (r *Router) Handle(name string, fn Func)

Handle registers fn under name. Names with whitespace or '=' are rejected because they would corrupt the TTFP line.

Jump to

Keyboard shortcuts

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