config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config manages layered CLI configuration (flags > env > config file > defaults) via an injected Viper instance and persists non-sensitive TUI user preferences (domain, username, theme, icon set, language, bookmarks). Passwords are never written to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveSaved

func SaveSaved(cfg SavedConfig) error

SaveSaved persists non-sensitive UI preferences to the user's OS config directory using owner-only permissions (0700 directory, 0600 file).

func SaveSavedTo

func SaveSavedTo(filePath string, cfg SavedConfig) error

SaveSavedTo persists non-sensitive UI preferences to filePath with 0700/0600 permissions.

func SaveSpotlightCache

func SaveSpotlightCache(domain, username string, entries []SpotlightEntry) error

SaveSpotlightCache persists a per-account Spotlight metadata index with 0700/0600 permissions.

func SaveSpotlightCacheTo

func SaveSpotlightCacheTo(baseDir, domain, username string, entries []SpotlightEntry) error

SaveSpotlightCacheTo persists a per-account Spotlight metadata index under baseDir.

func SpotlightAccountKey

func SpotlightAccountKey(domain, username string) string

SpotlightAccountKey returns a deterministic, filesystem-safe hash uniquely identifying a (domain, username) account pair so caches never leak across accounts.

func SpotlightCachePath

func SpotlightCachePath(baseDir, domain, username string) (string, error)

SpotlightCachePath resolves the per-account Spotlight index path under baseDir (or the user's OS cache directory when baseDir is empty).

Types

type AppConfig

type AppConfig struct {
	Domain            string        `mapstructure:"domain"`
	Username          string        `mapstructure:"username"`
	Password          string        `mapstructure:"password"`
	Output            string        `mapstructure:"output"`
	Timeout           time.Duration `mapstructure:"timeout"`
	AllowInsecureHTTP bool          `mapstructure:"allow_insecure_http"`
	DebugLog          string        `mapstructure:"debug_log"`
	Theme             string        `mapstructure:"theme"`
	IconSet           string        `mapstructure:"icon_set"`
	Language          string        `mapstructure:"language"`
	DownloadsDir      string        `mapstructure:"downloads_dir"`
	ExportsDir        string        `mapstructure:"exports_dir"`
	NoColor           bool          `mapstructure:"no_color"`
}

AppConfig holds the effective runtime configuration resolved across flags > environment variables (ISERV_*) > config file > saved UI state > defaults. Password is only ever accepted from flags or environment variables and is never written to disk.

func Load

func Load(v *viper.Viper, flags *pflag.FlagSet, opts LoaderOptions) (AppConfig, error)

Load resolves AppConfig using a fresh, isolated *viper.Viper instance so callers and tests never share global Viper state.

type Bookmark

type Bookmark struct {
	Label  string `json:"label"`
	Kind   string `json:"kind"` // "files" or "group"
	Path   string `json:"path"`
	IsFile bool   `json:"is_file,omitempty"`
}

Bookmark represents a pinned IServ group or directory shortcut in the TUI.

type LoaderOptions

type LoaderOptions struct {
	ConfigFile    string
	SavedState    *SavedConfig
	DefaultCfgDir string
}

LoaderOptions controls where config files and saved TUI state are loaded from.

type SavedConfig

type SavedConfig struct {
	Domain    string     `json:"domain"`
	Username  string     `json:"username"`
	ThemeName string     `json:"theme_name,omitempty"`
	IconSet   string     `json:"icon_set,omitempty"`
	Language  string     `json:"language,omitempty"`
	Bookmarks []Bookmark `json:"bookmarks,omitempty"`
}

SavedConfig stores non-sensitive connection defaults and TUI preferences. Passwords are never persisted.

func LoadSaved

func LoadSaved() SavedConfig

LoadSaved reads saved UI preferences from the user's OS config directory.

func LoadSavedFrom

func LoadSavedFrom(filePath string) SavedConfig

LoadSavedFrom reads saved UI preferences from an explicit file path.

type SpotlightEntry

type SpotlightEntry struct {
	Kind      string `json:"kind"`
	Title     string `json:"title"`
	Subtitle  string `json:"subtitle,omitempty"`
	Path      string `json:"path,omitempty"`
	ID        string `json:"id,omitempty"`
	IsDir     bool   `json:"is_dir,omitempty"`
	UpdatedAt int64  `json:"updated_at,omitempty"`
}

SpotlightEntry stores a lightweight metadata pointer (path, title, ID) for Spotlight omni-search. File contents, email bodies, and passwords are never stored.

func LoadSpotlightCache

func LoadSpotlightCache(domain, username string) []SpotlightEntry

LoadSpotlightCache loads the persisted Spotlight metadata index for (domain, username).

func LoadSpotlightCacheFrom

func LoadSpotlightCacheFrom(baseDir, domain, username string) []SpotlightEntry

LoadSpotlightCacheFrom loads a per-account Spotlight metadata index from baseDir.

func MergeSpotlightEntries

func MergeSpotlightEntries(existing, incoming []SpotlightEntry, maxItems int) []SpotlightEntry

MergeSpotlightEntries upserts incoming entries into existing, preserving newest entries first and capping total size at maxItems.

Jump to

Keyboard shortcuts

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