doctor

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package doctor implements the diagnostic check runner shared by the `ctm doctor` CLI and the `GET /api/doctor` HTTP endpoint.

The CLI formats ok/warn/err Check slices as coloured lines; the HTTP endpoint JSON-encodes the same slice. Adding a new check means appending one function here — both surfaces pick it up without edits.

Index

Constants

View Source
const (
	StatusOK   = "ok"
	StatusWarn = "warn"
	StatusErr  = "err"
)

Status enumerates the three check outcomes surfaced to both CLI and UI. Values are the wire form — do not rename without bumping the API.

Variables

This section is empty.

Functions

func LookupBinary

func LookupBinary(name string) (path string, ok bool)

LookupBinary resolves a named binary on PATH. Exposed so the CLI formatter (cmd/doctor.go) can share the exact same probe logic rather than shelling out a second time.

func TmuxVersion

func TmuxVersion(ctx context.Context) (version string, ok bool)

TmuxVersion runs `tmux -V` under ctx and returns the trimmed output. ok=false means tmux is either missing or refused to print a version.

Types

type Check

type Check struct {
	Name        string `json:"name"`
	Status      string `json:"status"`
	Message     string `json:"message,omitempty"`
	Remediation string `json:"remediation,omitempty"`
}

Check is the single result row. JSON tags are the /api/doctor wire contract; Remediation is optional and omitted when empty.

func Run

func Run(ctx context.Context, cfg config.Config) []Check

Run executes every diagnostic check and returns the results in display order. All checks respect ctx cancellation; Run returns immediately with whatever it has accumulated if ctx expires.

cfg is the already-loaded user config. A zero-valued Config is legal: checks that depend on user-configurable lists (required_env, required_in_path) simply report "not configured".

Jump to

Keyboard shortcuts

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