config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionFocusTables    = "focus_tables"
	ActionFocusQuery     = "focus_query"
	ActionFocusResults   = "focus_results"
	ActionDashboard      = "dashboard"
	ActionHelp           = "help"
	ActionServices       = "services"
	ActionFullscreen     = "fullscreen"
	ActionBackup         = "backup"
	ActionExportCSV      = "export_csv"
	ActionHistory        = "history"
	ActionSettings       = "settings"
	ActionImportDump     = "import_dump"
	ActionSelectAll      = "select_all"
	ActionClearSelection = "clear_selection"
)

Variables

This section is empty.

Functions

func DefaultKeymapBindings

func DefaultKeymapBindings() map[string][]string

DefaultKeymapBindings returns a deep copy of default key bindings.

func SaveSettings

func SaveSettings(settings *Settings) error

SaveSettings saves settings to ~/.config/dbterm/settings.json.

Types

type ConnectionConfig

type ConnectionConfig struct {
	Name       string `json:"name"`
	Type       DBType `json:"type"`
	Host       string `json:"host,omitempty"`
	Port       string `json:"port,omitempty"`
	User       string `json:"user,omitempty"`
	Password   string `json:"password,omitempty"`
	Database   string `json:"database,omitempty"`
	ReadOnly   bool   `json:"read_only,omitempty"`
	FilePath   string `json:"file_path,omitempty"`   // SQLite only
	SSLMode    string `json:"ssl_mode,omitempty"`    // PostgreSQL only
	AccountID  string `json:"account_id,omitempty"`  // Cloudflare D1 only
	DatabaseID string `json:"database_id,omitempty"` // Cloudflare D1 only
	AuthToken  string `json:"auth_token,omitempty"`  // Turso & D1
	LastUsed   string `json:"last_used,omitempty"`
	Active     bool   `json:"active"`
}

ConnectionConfig holds all info for a saved database connection

func (*ConnectionConfig) BuildConnString

func (c *ConnectionConfig) BuildConnString() string

BuildConnString creates a driver-appropriate connection string

func (*ConnectionConfig) DisplayLabel

func (c *ConnectionConfig) DisplayLabel() string

DisplayLabel returns a human-friendly label for the connection

func (*ConnectionConfig) DriverName

func (c *ConnectionConfig) DriverName() string

DriverName returns the Go sql driver name for this config

func (*ConnectionConfig) TypeLabel

func (c *ConnectionConfig) TypeLabel() string

TypeLabel returns a styled label for the DB type

type DBType

type DBType string

DBType represents the supported database types

const (
	PostgreSQL   DBType = "postgresql"
	MySQL        DBType = "mysql"
	SQLite       DBType = "sqlite"
	Turso        DBType = "turso"
	CloudflareD1 DBType = "d1"
)

type Settings

type Settings struct {
	Keymap map[string][]string `json:"keymap"`
}

Settings stores user-adjustable runtime settings.

func DefaultSettings

func DefaultSettings() *Settings

DefaultSettings returns a deep-copied default settings value.

func LoadSettings

func LoadSettings() (*Settings, error)

LoadSettings loads settings from ~/.config/dbterm/settings.json. Missing or empty files are replaced with defaults on disk.

type Store

type Store struct {
	Connections []ConnectionConfig `json:"connections"`
	// contains filtered or unexported fields
}

Store manages the collection of saved connections

func LoadStore

func LoadStore() (*Store, error)

LoadStore reads saved connections from disk, or returns an empty store

func (*Store) Add

func (s *Store) Add(c ConnectionConfig) error

Add appends a new connection and saves

func (*Store) Delete

func (s *Store) Delete(index int) error

Delete removes a connection at the given index and saves

func (*Store) MarkUsed

func (s *Store) MarkUsed(index int) error

MarkUsed updates the LastUsed timestamp and Active flag for a connection

func (*Store) Save

func (s *Store) Save() error

Save writes the current store to disk

func (*Store) Update

func (s *Store) Update(index int, c ConnectionConfig) error

Update replaces a connection at the given index and saves

Jump to

Keyboard shortcuts

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