datatugui

package
v0.51.6 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package datatugui is the application layer of the DataTug terminal UI: the registry of root modules, the shared main menu, the Bubble Tea app model that hosts the tuigoff navigation shell, and the helpers every screen uses.

A root module (projects, viewers, settings, API monitor) describes itself with a Module value and the app is assembled from them:

err := datatugui.Run(
	[]datatugui.Module{dtproject.Module(), dtviewers.Module(), ...},
	datatugui.Options{Start: datatugui.ScreenViewers},
)

Nothing here calls back: highlighting a menu item, opening a module and opening the web UI are messages handled by App. See docs/tui-screens.md for how to write a screen.

Index

Constants

View Source
const (
	ScreenProjects   = "projects"
	ScreenViewers    = "viewers"
	ScreenSettings   = "settings"
	ScreenAPIMonitor = "api_monitor"
)

Identifiers of the root modules. They are also the first element of the screen path persisted by dtstate, which is how the app returns to the screen the user left.

View Source
const DefaultWebUIOrigin = "https://datatug.app"

DefaultWebUIOrigin is the DataTug web UI the CLI hands off to unless overridden in settings.

View Source
const MenuID = "datatug.menu"

MenuID identifies the main menu list in its messages.

View Source
const RootTitle = "⛴ DataTug"

RootTitle is the root breadcrumb.

Variables

This section is empty.

Functions

func CurrentScreenWebUIURL added in v0.11.0

func CurrentScreenWebUIURL() string

CurrentScreenWebUIURL resolves the web UI URL for the current TUI screen, using the origin from settings (default https://datatug.app).

func Drill added in v0.51.4

func Drill(title string, content nav.Screen) tea.Cmd

Drill returns the command that opens a screen one level deeper: a page whose title is added to the breadcrumbs and whose content takes focus. The page keeps the menu that is showing.

func Open added in v0.51.4

func Open(id string, focus nav.FocusTo) tea.Cmd

Open returns the command that opens the module with the given ID, for a screen that has to go back to a root screen, such as after a project was created.

func OpenCurrentScreenInWebUI added in v0.11.0

func OpenCurrentScreenInWebUI() tea.Cmd

OpenCurrentScreenInWebUI returns the command that opens the current TUI screen in the web UI in the default browser. It yields an alert when the browser cannot be opened. Bound app-wide to Ctrl+W.

func ReportError added in v0.51.4

func ReportError(what string, err error) tea.Cmd

ReportError returns the command that logs a failed action and shows the error in the content panel, where the previous imperative shell panicked. what says what was being done. A nil err yields no command.

func RootPage added in v0.51.4

func RootPage(modules []Module, opts Options) nav.Page

RootPage returns the root page of the app: the breadcrumb, the shared main menu and an empty content until the start module opens. It panics for an invalid or duplicate module.

func Run added in v0.51.4

func Run(modules []Module, opts Options, programOptions ...tea.ProgramOption) error

Run assembles the app from modules and runs it full-screen until it exits. programOptions go to tea.NewProgram. A panic inside the app quits the program first, so the terminal is restored, and is then raised again from Run.

func ScreenOpened added in v0.51.4

func ScreenOpened(path, name string) tea.Cmd

ScreenOpened returns the command that records that a screen was opened: telemetry and the persisted screen path, whose first element (the module ID) is where the next start resumes. The app runs it for every module; a screen deeper than the root may run it with a longer path such as "viewers/sql".

func StartScreen added in v0.51.4

func StartScreen(modules []Module, currentScreenPath string) string

StartScreen resolves the module to show at startup from the persisted screen path (for example "viewers/sql"): its first element when a module of that ID is registered, otherwise the projects screen, otherwise the first module.

func WebUIURLForScreen added in v0.11.0

func WebUIURLForScreen(origin, screenPath string) string

WebUIURLForScreen resolves the web UI URL for a TUI screen path.

Types

type App added in v0.51.4

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

App is the root tea.Model of the DataTug terminal UI. It hosts the nav shell, handles the application-wide messages (OpenModuleMsg, OpenWebUIMsg) that must work whichever menu is showing, and turns a panic in Update or View into an orderly exit: the program quits, Bubble Tea restores the terminal, and Run raises the panic again so the caller's recovery reports it.

func New added in v0.51.4

func New(modules []Module, opts Options, navOptions ...nav.Option) App

New creates the app.

func (App) Init added in v0.51.4

func (a App) Init() tea.Cmd

Init implements tea.Model.

func (App) Shell added in v0.51.4

func (a App) Shell() nav.Model

Shell returns the navigation shell, for tests that inspect the screens.

func (App) Update added in v0.51.4

func (a App) Update(msg tea.Msg) (model tea.Model, cmd tea.Cmd)

Update implements tea.Model.

func (App) View added in v0.51.4

func (a App) View() (view tea.View)

View implements tea.Model.

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

MainMenu is the menu panel shared by every root module: one item per module and a final Exit. Highlighting an item opens its module with focus kept on the menu, Enter moves focus to the content, and Exit saves an empty screen path and quits. A module never builds it: the app mounts it once in the root page and every module page keeps it.

func NewMainMenu added in v0.51.4

func NewMainMenu(modules []Module) MainMenu

NewMainMenu creates the menu of modules. It panics for an invalid or duplicate module.

func (m MainMenu) AtEdge(dir widgets.Direction) bool

AtEdge implements widgets.Boundary.

func (m MainMenu) Init() tea.Cmd

Init implements nav.Screen.

func (m MainMenu) ShortHelp() []key.Binding

ShortHelp implements nav.ShortHelper.

func (m MainMenu) Update(msg tea.Msg) (nav.Screen, tea.Cmd)

Update implements nav.Screen.

func (m MainMenu) View() string

View implements nav.Screen.

type Module added in v0.51.4

type Module struct {
	// ID identifies the module and is persisted as the current screen path;
	// use one of the Screen constants.
	ID string
	// Text is the menu label.
	Text string
	// Shortcut is the key that opens the module from the menu.
	Shortcut rune
	// Root builds the page of the module. Its Content is the module's root
	// screen. Menu is ignored: the shared main menu always stays. An empty
	// Title defaults to Text; Focus is set by the app.
	Root func() nav.Page
}

Module is a root screen of the app, listed in the main menu.

type OpenModuleMsg added in v0.51.4

type OpenModuleMsg struct {
	ID    string
	Focus nav.FocusTo
}

OpenModuleMsg opens the root screen of a module: the stack is reduced to the root page and the module's page is pushed, its menu item highlighted.

type OpenWebUIMsg added in v0.51.4

type OpenWebUIMsg struct{}

OpenWebUIMsg asks the app to open the current screen in the web UI.

type Options added in v0.51.4

type Options struct {
	// Start is the ID of the module shown first; see StartScreen. An unknown or
	// empty ID shows the first module.
	Start string
	// Initial, when not nil, is a page pushed on top of the start module, for
	// example the database opened with `datatug ui -f file.db`.
	Initial *nav.Page
}

Options customise the app.

Directories

Path Synopsis
Package dtapiservice is the API Monitor screen of the DataTug terminal UI.
Package dtapiservice is the API Monitor screen of the DataTug terminal UI.
Package dtproject is the Projects module of the DataTug terminal UI: the list of local and GitHub projects, the screens of an open project, the wizard that creates a project and the flow that adds DataTug to an existing GitHub repository.
Package dtproject is the Projects module of the DataTug terminal UI: the list of local and GitHub projects, the screens of an open project, the wizard that creates a project and the flow that adds DataTug to an existing GitHub repository.
Package dtsettings is the Settings screen of the DataTug terminal UI: the config file, syntax highlighted.
Package dtsettings is the Settings screen of the DataTug terminal UI: the config file, syntax highlighted.
clouds
Package clouds holds what the cloud viewers (Google Cloud, AWS, Azure) share.
Package clouds holds what the cloud viewers (Google Cloud, AWS, Azure) share.
clouds/aws/awsui
Package awsui is the Amazon Web Services viewer.
Package awsui is the Amazon Web Services viewer.
clouds/azure/azureui
Package azureui is the Microsoft Azure viewer.
Package azureui is the Microsoft Azure viewer.
clouds/gcloud/gcloudui
Package gcloudui is the Google Cloud viewer: projects, credentials and the Firestore databases of a project.
Package gcloudui is the Google Cloud viewer: projects, credentials and the Firestore databases of a project.
dbviewer
Package dbviewer is the DB viewer of the Viewers module: a chooser of database kinds, the SQLite and inGitDB home screens, and the browser of one database (tables and views, their columns, foreign keys, referrers and content).
Package dbviewer is the DB viewer of the Viewers module: a chooser of database kinds, the SQLite and inGitDB home screens, and the browser of one database (tables and views, their columns, foreign keys, referrers and content).

Jump to

Keyboard shortcuts

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