Documentation
¶
Overview ¶
Package userconfig persists per-machine user preferences for the system tray (auto-start toggles, default project, self-update state) in a single JSON file under the OS user-config directory.
One installed binary = one config file. The directory is named after the running binary, so a user who installs the same app under two different names ("wick-manager", "client-tools") gets two separate configs without collision.
Path per OS:
Windows : %APPDATA%\<binary>\config.json macOS : ~/Library/Application Support/<binary>/config.json Linux : ~/.config/<binary>/config.json
Settings here are machine-wide, not per-project. Per-project state (e.g., wick app data) still lives in the project's wick.db.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Path ¶
Path returns the absolute config file path for the given project name. Empty name falls back to the running binary's basename.
func ResolveDBPath ¶
func ResolveDBPath(appName, customPath string)
ResolveDBPath determines the SQLite DB path and sets DATABASE_URL so config.Load() picks it up wherever it is called next.
Resolution order (first non-empty wins, never overwrites a higher priority):
- DATABASE_URL env already set (explicit env / CI override) → untouched
- cfg.DatabasePath set (user edited database_path in config.json)
- <binary_dir>/wick.db when wick.yml exists next to the binary (project mode)
- <UserConfigDir>/<appName>/wick.db (standalone / downloaded binary)
func ResolvePort ¶
func ResolvePort(customPort int)
ResolvePort sets the PORT env from cfg.Port so config.Load() picks it up wherever it is called next.
Resolution order (first non-empty wins, never overwrites a higher priority):
- PORT env already set (explicit env / CI override) → untouched
- customPort > 0 (user edited port in config.json)
- fall through → env.go envDefault picks the built-in default (9425)
Types ¶
type Config ¶
type Config struct {
// AutoStartApp registers the binary with the OS so it launches at
// user login (Windows: Run registry, macOS: LaunchAgent plist,
// Linux: XDG autostart .desktop). Toggle from Preferences ▶ Auto-start app.
AutoStartApp bool `json:"auto_start_app"`
// Tray auto-start toggles — applied at the next tray launch.
AutoStartServer bool `json:"auto_start_server"`
AutoStartWorker bool `json:"auto_start_worker"`
// Self-update toggle.
AutoUpdate bool `json:"auto_update"`
// Port overrides the HTTP listen port. 0 = use env PORT or default 9425.
// Set this in config.json to pin a custom port without touching .env.
Port int `json:"port,omitempty"`
// LogRetentionDays controls how many days of per-day log files are
// kept. 0 = use built-in default (7). Set in config.json to override.
LogRetentionDays int `json:"log_retention_days,omitempty"`
// DatabasePath overrides the SQLite DB location. Empty = auto-detect.
// Auto-detect: binary dir has wick.yml → <binary_dir>/wick.db,
// otherwise %APPDATA%/<appName>/wick.db (Windows) or equivalent.
// Set this manually in config.json if you need a custom location.
DatabasePath string `json:"database_path,omitempty"`
// Update state — managed by the updater, not user-facing.
StagedUpdatePath string `json:"staged_update_path,omitempty"`
StagedUpdateVersion string `json:"staged_update_version,omitempty"`
}
Config is the on-disk shape. Add fields with `json:"...,omitempty"` so older config files keep working when the binary upgrades.