tui

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tui provides the DevTUI execution handler for DDL export.

This package is intentionally separate from the ddlc root package: the root stays a WASM-safe leaf contract (Exporter, FieldExt, TopologicalSort) consumed by sqlt/postgres/ormc/sqlmcp, while this package pulls in os/file I/O and the DevTUI execution contract and is only meant to be imported by tinywasm/app's dev console.

Index

Constants

View Source
const (
	LogOpen          = "[..."
	LogClose         = "...]"
	MsgPrefix        = "ddlc handler: "
	MsgExporting     = "Exporting DDL schema..."
	MsgExportFailed  = "Export failed: "
	MsgExportSuccess = "Export successful. Written to: "
	MsgWriteFailed   = "Write failed: "
	ErrNotConfigured = "ddlc handler: export function not configured"
)

Log message prefix and message constants to avoid repeating string literals.

View Source
const DefaultOutputPath = "config/db.sql"

DefaultOutputPath is used when SetOutputPath is never called.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExportFunc

type ExportFunc func() (sql string, err error)

ExportFunc produces the DDL SQL for the current project.

type Handler

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

Handler implements the TUI HandlerExecution and Loggable interfaces structurally.

func New

func New() *Handler

New creates a new DDLC TUI handler.

func (*Handler) Execute

func (h *Handler) Execute()

Execute triggers the DDL export. Implements devtui.HandlerExecution structurally.

func (*Handler) ExecuteErr

func (h *Handler) ExecuteErr() error

ExecuteErr executes the export, writes the result to outputPath, and returns the error for test assertion.

func (*Handler) Label

func (h *Handler) Label() string

Label returns the button label for DevTUI.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the TUI handler identifier.

func (*Handler) SetExport

func (h *Handler) SetExport(fn ExportFunc)

SetExport injects the DDL export logic.

func (*Handler) SetLog

func (h *Handler) SetLog(fn func(messages ...any))

SetLog injects the logging function.

func (*Handler) SetOutputPath

func (h *Handler) SetOutputPath(path string)

SetOutputPath overrides the file the generated DDL is written to. Empty path resets to DefaultOutputPath.

Jump to

Keyboard shortcuts

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