config

package
v0.7.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Enhanced config.go for the client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the platform-appropriate configuration directory

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the full path to the config file

func GetKeystorePath

func GetKeystorePath() (string, error)

GetKeystorePath returns the full path to the keystore file Checks old location (current directory) first for backward compatibility

func MigrateKeystoreToNewLocation

func MigrateKeystoreToNewLocation() error

MigrateKeystoreToNewLocation migrates keystore from legacy location to new platform-appropriate location

func RunProfileSelection

func RunProfileSelection(profiles []ConnectionProfile) (int, error)

RunProfileSelection runs the profile selection UI (for quick-start)

func RunProfileSelectionWithNew

func RunProfileSelectionWithNew(profiles []ConnectionProfile) (int, bool, error)

RunProfileSelectionWithNew runs the profile selection UI with "Create New" option

func SaveConfig

func SaveConfig(path string, cfg Config) error

Types

type Config

type Config struct {
	// Connection settings
	Username  string `json:"username"`
	ServerURL string `json:"server_url"`

	// Admin settings (optional)
	IsAdmin  bool   `json:"is_admin,omitempty"`
	AdminKey string `json:"admin_key,omitempty"` // Note: Consider security implications

	// E2E Encryption settings (optional)
	UseE2E bool `json:"use_e2e,omitempty"`

	// UI settings
	Theme          string `json:"theme"`
	TwentyFourHour bool   `json:"twenty_four_hour"`
	SkipTLSVerify  bool   `json:"skip_tls_verify,omitempty"`

	// Bell notification settings
	EnableBell    bool `json:"enable_bell,omitempty"`     // Enable/disable bell
	BellOnMention bool `json:"bell_on_mention,omitempty"` // Only bell on mentions

	// Quick start settings
	SaveCredentials bool  `json:"save_credentials"`
	LastUsed        int64 `json:"last_used,omitempty"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

func RunInteractiveConfig

func RunInteractiveConfig() (*Config, string, error)

RunInteractiveConfig runs the interactive configuration UI

type ConfigUIModel

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

func NewConfigUI

func NewConfigUI() ConfigUIModel

func (ConfigUIModel) GetConfig

func (m ConfigUIModel) GetConfig() *Config

GetConfig returns the built configuration

func (ConfigUIModel) GetKeystorePassphrase

func (m ConfigUIModel) GetKeystorePassphrase() string

GetKeystorePassphrase returns the keystore passphrase

func (ConfigUIModel) Init

func (m ConfigUIModel) Init() tea.Cmd

func (ConfigUIModel) IsCancelled

func (m ConfigUIModel) IsCancelled() bool

IsCancelled returns true if the user cancelled the configuration

func (ConfigUIModel) IsFinished

func (m ConfigUIModel) IsFinished() bool

IsFinished returns true if the user completed the configuration

func (ConfigUIModel) Update

func (m ConfigUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (ConfigUIModel) View

func (m ConfigUIModel) View() string

type ConnectionProfile

type ConnectionProfile struct {
	Name      string `json:"name"`
	ServerURL string `json:"server_url"`
	Username  string `json:"username"`
	IsAdmin   bool   `json:"is_admin"`
	UseE2E    bool   `json:"use_e2e"`
	Theme     string `json:"theme,omitempty"`
	LastUsed  int64  `json:"last_used,omitempty"` // Unix timestamp
}

ConnectionProfile represents a saved connection profile

type InteractiveConfigLoader

type InteractiveConfigLoader struct {
	ConfigPath   string
	ProfilesPath string
	// contains filtered or unexported fields
}

InteractiveConfigLoader handles interactive configuration

func NewInteractiveConfigLoader

func NewInteractiveConfigLoader() (*InteractiveConfigLoader, error)

func (*InteractiveConfigLoader) AutoConnect

func (icl *InteractiveConfigLoader) AutoConnect() (*Config, error)

AutoConnect automatically connects to the most recently used profile

func (*InteractiveConfigLoader) FormatSanitizedLaunchCommand

func (icl *InteractiveConfigLoader) FormatSanitizedLaunchCommand(cfg *Config) string

FormatSanitizedLaunchCommand creates a version safe for logging (without sensitive data)

func (*InteractiveConfigLoader) LoadOrPromptConfig

func (icl *InteractiveConfigLoader) LoadOrPromptConfig(overrides map[string]interface{}) (*Config, string, string, string, error)

LoadOrPromptConfig loads existing config or prompts for new configuration

func (*InteractiveConfigLoader) LoadProfiles

func (icl *InteractiveConfigLoader) LoadProfiles() (*Profiles, error)

func (*InteractiveConfigLoader) PromptSensitiveData

func (icl *InteractiveConfigLoader) PromptSensitiveData(isAdmin, useE2E bool) (adminKey, keystorePass string, err error)

PromptSensitiveData prompts for admin key and/or keystore passphrase

func (*InteractiveConfigLoader) QuickStartConnect

func (icl *InteractiveConfigLoader) QuickStartConnect() (*Config, error)

QuickStartConnect shows profiles and connects to selected one

func (*InteractiveConfigLoader) SaveProfiles

func (icl *InteractiveConfigLoader) SaveProfiles(profiles *Profiles) error

type ProfileSelectionModel

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

ProfileSelectionModel handles profile selection UI

func NewProfileSelectionModel

func NewProfileSelectionModel(profiles []ConnectionProfile, showNewOption bool) ProfileSelectionModel

func (ProfileSelectionModel) GetChoice

func (m ProfileSelectionModel) GetChoice() int

func (ProfileSelectionModel) Init

func (m ProfileSelectionModel) Init() tea.Cmd

func (ProfileSelectionModel) IsCancelled

func (m ProfileSelectionModel) IsCancelled() bool

func (ProfileSelectionModel) IsCreateNew

func (m ProfileSelectionModel) IsCreateNew() bool

IsCreateNew returns true if user selected "Create New Profile"

func (ProfileSelectionModel) IsSelected

func (m ProfileSelectionModel) IsSelected() bool

func (ProfileSelectionModel) Update

func (m ProfileSelectionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (ProfileSelectionModel) View

func (m ProfileSelectionModel) View() string

type Profiles

type Profiles struct {
	Default  string              `json:"default,omitempty"`
	Profiles []ConnectionProfile `json:"profiles"`
}

Jump to

Keyboard shortcuts

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