package lazycli

import "golazy.dev/lazytui/lazycli"

Package lazycli provides a small reflection-driven command router.

Functions

func Execute

Execute draws and runs a command tree. It returns a process-style exit code.

func Execute(ctx context.Context, draw Drawer, config ExecuteConfig) int

func Exit

Exit returns an error that stops command execution with code without printing another diagnostic. A zero code returns nil.

func Exit(code int) error

func Func

Func adapts func(context.Context, Params) error into a command controller.

func Func(handler any) any

func Main

Main executes a drawer using the process arguments and streams.

func Main(draw Drawer)

func Params[T any]

Params returns the parsed parameter struct of type T for the invocation.

func Params[T any](ctx context.Context) T

Types

type Command

Command configures one command scope. Empty presentation fields inherit from lower merged layers and, for Logo and Palette, from parent scopes.

type Command struct {
	Name		string
	Help		string
	Description	string
	Hidden		bool
	Disabled	bool
	Default		bool
	Logo		string
	Palette		lazytui.Palette
	Controller	any
	Method		string
	Autocomplete	bool
}

type Controller

Controller is a zero-size controller type reference. It lets a router expose method metadata without constructing the controller during help or completion.

type Controller[T any] struct{}

type Scope

Scope builds a command tree. Repeated definitions overlay the existing node; controllers are composed in definition order.

type Scope interface {
	Root(Command)
	Define(name string, command Command)
	Group(name string, command Command, draw Drawer)
	Merge(Drawer)
}