commands

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]*CommandHandler{}

Functions

func BuildCobraCommands

func BuildCobraCommands(ctx *ExecContext) []*cobra.Command

func CloseAllDBConns added in v0.2.18

func CloseAllDBConns(ctx *ExecContext)

CloseAllDBConns closes every connection registered on ctx and clears the map. Used by the REPL on shutdown.

func Dispatch

func Dispatch(ctx *ExecContext, name string, args []string) error

func Register

func Register(handler *CommandHandler) error

Types

type CommandHandler

type CommandHandler struct {
	Name        string
	Aliases     []string
	Usage       string
	Description string
	// Forms lists the major sub-shapes of a command (one entry per shape).
	// Each entry is rendered as-is under a "Forms:" header by `help <cmd>`.
	// Use for commands like `ttest single|two|paired` where the bare Usage
	// can't enumerate every form.
	Forms []string
	// Examples lists ready-to-run invocations rendered under "Examples:" by
	// `help <cmd>`. Each entry should be a complete `insyra ...` line that
	// the user can copy into a shell.
	Examples           []string
	DisableFlagParsing bool
	Run                func(ctx *ExecContext, args []string) error
}

type DBConn added in v0.2.18

type DBConn struct {
	Name    string
	Dialect string // "sqlite", "mysql", "postgres"
	DSN     string // original DSN string supplied by the user (with password masked when displayed)
	DB      *gorm.DB
}

DBConn represents a named database connection registered in an ExecContext.

type ExecContext

type ExecContext struct {
	Vars     map[string]any
	DBConns  map[string]*DBConn
	EnvName  string
	EnvPath  string
	Output   io.Writer
	InREPL   bool
	OpenREPL func(ctx *ExecContext) error
	// Env is the per-session environment Manager. Commands MUST go through
	// it (ctx.Env.SaveState etc.) so embedders that supply a per-workspace
	// Manager don't get their writes redirected to the default ~/.insyra.
	// Dispatch fills this with env.Default() if the caller left it nil.
	Env *env.Manager
}

Jump to

Keyboard shortcuts

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