config

package
v0.1.0-pre-release Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

internal/config/config.go

internal/config/flags.go

Index

Constants

View Source
const AppName = "tide"

Base application details

View Source
const ConfigDirName = "tide"
View Source
const DefaultConfigFileName = "config.toml" // Main config file
View Source
const DefaultLeaderKey = ','

Input Behavior

View Source
const DefaultLogFileName = "tide.log"
View Source
const DefaultScrollOff = 3
View Source
const DefaultTabWidth = 4

These could be moved to NewDefaultConfig(), keeping here for now

View Source
const DefaultThemeFileName = "theme.toml" // Active theme file
View Source
const LeaderTimeout = 500 * time.Millisecond
View Source
const MessageTimeout = 4 * time.Second

Status Bar

View Source
const StatusBarHeight = 1

UI Layout

View Source
const SystemClipboard = true
View Source
const ThemesDirName = "themes"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger logger.Config `toml:"logger"` // Embed logger config under [logger] table
	Editor EditorConfig  `toml:"editor"` // Editor-specific settings

}

Config holds the application's combined configuration.

func Get

func Get() *Config

Get returns the loaded application configuration. Panics if LoadConfig wasn't called.

func LoadConfig

func LoadConfig(configFilePath string, flags *Flags) (*Config, error)

LoadConfig orchestrates loading defaults, file, applying flags, and validation. It should be called only once, typically from main.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates a Config struct with default values.

type EditorConfig

type EditorConfig struct {
	TabWidth        int  `toml:"tab_width"`
	ScrollOff       int  `toml:"scroll_off"`
	SystemClipboard bool `toml:"system_clipboard"`
	StatusBarHeight int  `toml:"status_bar_height"` // Add StatusBarHeight

}

EditorConfig holds editor-specific settings.

type Flags

type Flags struct {
	ConfigFilePath *string
	Version        *bool
	LogLevel       *string
	LogFilePath    *string
	TabWidth       *int
	ScrollOff      *int
	// Add flags for logger filters
	EnableTags      *string
	DisableTags     *string
	EnablePkgs      *string
	DisablePkgs     *string
	EnableFiles     *string
	DisableFiles    *string
	DebugLog        *bool
	SystemClipboard *bool
}

Flags holds values parsed from command-line flags. Use pointers to distinguish between unset flags and zero-value flags.

func (*Flags) ApplyOverrides

func (f *Flags) ApplyOverrides(cfg *Config, verbose bool)

ApplyOverrides updates the Config struct with values from flags *if* they were set.

func (*Flags) DefineFlags

func (f *Flags) DefineFlags()

DefineFlags sets up the command-line flags and associates them with the Flags struct fields.

func (*Flags) ParseFlags

func (f *Flags) ParseFlags() []string

ParseFlags parses the defined command-line flags into the Flags struct. It returns the remaining non-flag arguments (e.g., the file path).

Jump to

Keyboard shortcuts

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